aloy Posted April 1, 2014 Share 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 Link to comment Share on other sites More sharing options...
Tharwat Posted April 1, 2014 Share Posted April 1, 2014 What are you trying to do Aloy ? a bit more info is required . Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 1, 2014 Share 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 Link to comment Share on other sites More sharing options...
aloy Posted April 1, 2014 Author Share 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 Link to comment Share on other sites More sharing options...
aloy Posted April 1, 2014 Author Share 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 Link to comment Share on other sites More sharing options...
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.