Hi ,
The extrusion vector option of trans is useful for defining an OCS, but
cannot be relied upon for just any random UCS. As it sounds like you know,
a single extrusion vector does not fully define a coordinate system. So
when you supply only an extrusion vector to trans it fills in the blanks
using the Arbitrary Axis Algorithm described in the DXF Reference. In other
words it uses the single OCS corresponding to the supplied vector, not
necessarily the UCS you intend it to. To my knowledge there is not a built
in function to translate coordinates to a random UCS without actually
presetting it current. However, you could make your own replacement for the
trans function that works how you want it to, or adapt or use similar
functions that have been posted in this newsgroup. Which direction do you
want to go with it?
--
James Allen, EIT
Malicoat-Winslow Engineers, P.C.
Columbia, MO
wrote in message news:5161379@discussion.autodesk.com...
hi,
could anyone help me with this? i've browsed around but i'm not finding
the exact answer - i want to change my ucs so that the new XY plane is
defined by three 3D points. then find p1local which is p1 translated into
the new UCS.
one way to do this is:
(command "UCS" "N" "3" p1 p2 p3)
(setq p1local (trans p1 0 1))
instead of above which takes super-long, i want to find the 3D extrusion
vector to pass into trans so that i can do (setq p1local (trans p1 '(0 0 1)
v1)) where v1 is the unit vector normal to the plane defined by p1 p2 and
p3. I think I'm getting the normal correctly (shown below) but when i pass
this vector into trans function, it doesn't work - this does not seem to be
the "3D extrusion vector" that trans wants as a parameter even though thet
fact that '(0 0 1) is 3D extrusion vectorfor WCS hints that it could be.
does this have anything to do with that the new UCS origin is always (0 0
0)?
can anyone tell me how i can calculate vector1 in (trans p1 '(0 0 1)
vector1) to get p1local?
thank you in advance,
;; kat park 2006
(defun C:getNormal ( Point1 Point2 Point3 )
(setq Edge1 (vectorDiff Point2 Point1)
Edge2 (vectorDiff Point3 Point1))
(setq crossed (cross-product Edge1 Edge2))
(setq normVal (vectorNorm crossed))
(setq unitVector (list (/ (car crossed) normVal)
(/ (cadr crossed) normVal)
(/ (caddr crossed) normVal)))
(eval 'unitVector)
)
; vector norm (length)
(defun vectorNorm (Point1)
(eval '(sqrt (+ (expt (car Point1) 2.0)
(expt (cadr Point1) 2.0)
(expt (caddr Point1) 2.0))))
)
; vector cross-product
; A x B = (Ay*Bz - Az*By) (Az*Bx - Ax*Bz) (Ax*By - Ay*Bx)
(defun cross-product (Point1 Point2)
(eval '(list (- (* (cadr Point1) (caddr Point2)) (* (caddr Point1) (cadr
Point2)))
(- (* (caddr Point1) (car Point2)) (* (car Point1) (caddr Point2)))
(- (* (car Point1) (cadr Point2)) (* (cadr Point1) (car Point2)))))
)
; subtract vector
; A - B = (Ax - Bx) (Ay - By) (Az - Bz)
(defun vectorDiff (Point1 Point2)
(eval '(list (- (car Point1) (car Point2))
(- (cadr Point1) (cadr Point2))
(- (caddr Point1) (caddr Point2)) ))
)