aloy Posted April 1, 2014 Posted April 1, 2014 Hi everyone, Are there built in functions to perform vector transformation ( perhaps using dot and cross products)?. If so, how can I access them. Thanking in advance, Aloy Quote
Tharwat Posted April 1, 2014 Posted April 1, 2014 What are you trying to do Aloy ? a bit more info is required . Quote
MSasu Posted April 1, 2014 Posted April 1, 2014 May want to check the mathematical functions kindly offered by LeeMac. ;; Vector Dot Product - Lee Mac ;; Args: u,v - vectors in R^n (defun vxv ( u v ) (apply '+ (mapcar '* u v)) ) ;; Vector Cross Product - Lee Mac ;; Args: u,v - vectors in R^3 (defun v^v ( u v ) (list (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u))) (- (* (car v) (caddr u)) (* (car u) (caddr v))) (- (* (car u) (cadr v)) (* (car v) (cadr u))) ) ) Quote
aloy Posted April 1, 2014 Author Posted April 1, 2014 Hi, Tharwat, What I am trying to do is explained in the following link: http://www.surveydrawing.net/find-point-3d-surface.html Since I posted the above I found the following function in the net that might help; have not tested yet to solve equations: (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)) )) ) Quote
aloy Posted April 1, 2014 Author Posted April 1, 2014 Hi, Mircea, Thanks for directing to Lee Mac's solutions. As explained to Tharwat, I already got another solution but what you have given appears much more elegant. Regards, Aloy Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.