;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;; Returns the single unit vector from p1 to p2
(defun kdub:vec2pts
(p1 p2
) )
)
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
(defun kdub:normal_from_3pts
(ip p1 p2
/ norm
) )
)
)
)
)
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
;;; Returns the angle (in radians) defined by its summit and two points
;;; Returned angle is always positive and less than or equal to pi radians.
;; Using vector calculus
(defun kdub:enclosedangle_3pts
(ip p1 p2
/ v1 v2
) (if (and (setq v1
(kdub:vec2pts ip p1
)) (setq v2
(kdub:vec2pts ip p2
))) (t
(* 2 (kdub:asin
(/ (distance v1 v2
) 2)))) )
)
)
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
(defun KDUB:GetEnclosedApexAngle
( apex p1 p2
) (- (+ pi pi
) (rem (+ pi pi
(- (angle apex p1
) (angle apex p2
))) (+ pi pi
))) )
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
(defun KDUB:GetApexAngle
<180 ( apex p1 p2
) )
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
;;; Returns the elevation of point pt from the plane defined by p1 p2 p3
(defun kdub:elevabovePlane
(pt p1 p2 p3
) (kdub:enclosedangle_3pts p1
(mapcar '
+ p1
(kdub:normal_from_3pts p1 p2 p3
)) pt
) )
)
)
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;; Returns the coordinates of the projection of point pt
;;; on the plane defined by the points p1 p2 p3.
(defun kdub:project_pt
(pt p1 p2 p3
) pt
(mapcar '
(lambda (x
) (* x
(kdub:elevabovePlane pt p1 p2 p3
))) (kdub:normal_from_3pts p1 p2 p3)
)
)
)
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
(defun kdub:vec:points
->vector
(3dPt1 3dPt2
) (mapcar '
- 3dPt2 3dPt1
)) ;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
;; VXS Multiply a vector by a scalar
;;
;; Arguments : a vector and a real
;;
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;; -- Function GetPathVector
;;; Returns the vector at start point from a given object.
;;; Arguments [Type]:
;;; Obj = Object [VLA-OBJECT]
;;; Return [Type]:
;;; > Vector [LIST]
;;; Notes:
;;; None
;;
(defun kdub:vec:getpathvector
(vlaObj
) (kdub:vec:normalize
)
)
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;; -- Function KDUB:VecNormalize
;;; Normalizes Vec to unit length (1.0).
;;; Arguments [Type]:
;;; Vec = Vector [LIST]
;;; Return [Type]:
;;; > Normalized vector [LIST]
;;; Notes:
;;; None
;;
(defun kdub:vec:normalize
(Vector
/ Coefficient
) (setq Coefficient
(/ 1.0 (kdub:vec:calculatelength Vector
))) (kdub:vec:zeroaxisfuzz
(mapcar '
* Vector
(list Coefficient Coefficient Coefficient
)) )
)
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
;;
;;; -- Function KDUB:eVecLen
;;; Calculates length of a vector.
;;; Arguments [Type]:
;;; Vec = Vector [LIST]
;;; Return [Type]:
;;; > Length of the vector [REAL]
;;; Notes:
;;; None
;;
(defun kdub:vec:calculatelength
(Vector
) (car (kdub:vec:zeroaxisfuzz
)
)
)
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
;;; Return the cross product, vec1 cross vec2
(defun kdub:vec:crossproduct
(vec1 vec2
) )
)
;;
;;;-------------------------------------------------------------
;;;-------------------------------------------------------------
;;
(defun kdub:vec:vla3dpoint
->list (vla3dPoint
) )
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;; arcsine (inverse sine) accepts an argument in the range
;;; -1.0 to 1.0 inclusive, and returns an angle in radians in
;;; the range -pi/2 to pi/2 inclusive.
(alert (strcat " Arc-sine error in (KDUB:asin ." "\n Spitting the dummy")) )
((= num 1.0) kglobal:rad90)
((= num -1.0) (- kglobal:rad90))
(t
(atan num
(sqrt (- 1.0 (* num num
))))) )
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;; arccosine (inverse cosine)
;;; argument in the range -1.0 to 1.0 inclusive
;;; returns an angle in radians in the range pi to 0 inclusive
;;;
(* pi 0.5)
)
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;;; (KDUB:defineconstant '*max_Real* 1.797693134862315e+308)
;; pass num as radian.
(defun kdub:tan
(num
/ cosnum
) ((zerop (rem num
(* pi
0.5))) *max_real
*) )
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;