Jonathan Handojo Posted April 19, 2020 Share Posted April 19, 2020 (edited) Hi again guys, Does anyone have a function to return a 3D point resulting from the polar function, provided a 3D point, angle, distance, and a normal vector? (From WCS btw) (the built-in polar function uses (0.0 0.0 1.0) as normal.) I didn't actually want to post this as I felt like I'm close to the solution (though struggling like crazy), but so close yet so far. Here's my pathetic attempt to this, provided that Z is not zero: ;; JH:3dpolar --> Jonathan Handojo ;; Returns a 3D point resulting from using the polar ;; function on a point rotating about a given normal ;; (polar uses the normal (0.0 0.0 1.0)) ;; pt - point to calculate ;; ang - angle in radians ;; dist - displacement ;; norm - 3D vector determining the normal (defun JH:3dpolar (pt ang dist norm) (setq vec (polar '(0 0 0) ang dist) vz (/ (- (apply '+ (mapcar '(lambda (x) (* (x norm) (x vec))) (list car cadr)))) (last norm)) ) (mapcar '+ pt (mapcar '(lambda (x) (* x dist)) (vx1 (list (car vec) (cadr vec) vz)))) ) ;; Unit Vector - Lee Mac ;; Args: v - vector in R^2 or R^3 (defun vx1 ( v ) ( (lambda ( n ) (if (equal 0.0 n 1e-10) nil (mapcar '/ v (list n n n)))) (distance '(0.0 0.0 0.0) v) ) ) Thanks Jonathan Handojo Edited April 19, 2020 by Jonathan Handojo Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 19, 2020 Share Posted April 19, 2020 (defun 3dpolar ( bpt ang dis nor ) (trans (polar (trans bpt 0 nor) ang dis) nor 0) ) 1 Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted April 19, 2020 Author Share Posted April 19, 2020 9 minutes ago, Lee Mac said: (defun 3dpolar ( bpt ang dis nor ) (trans (polar (trans bpt 0 nor) ang dis) nor 0) ) Lol, why do you make it look so easy? And you figured out in a short time... Thanks again Lee 1 Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted April 19, 2020 Share Posted April 19, 2020 A little too late: (defun test (pt ang dist norm) (mapcar '+ pt (trans (polar '(0 0 0) ang dist) norm 0 T)) ) Of course the trans function defines a custom CS based on a single normal. The OP may not want to follow that algorithm. Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted April 19, 2020 Author Share Posted April 19, 2020 34 minutes ago, Roy_043 said: A little too late: (defun test (pt ang dist norm) (mapcar '+ pt (trans (polar '(0 0 0) ang dist) norm 0 T)) ) Of course the trans function defines a custom CS based on a single normal. The OP may not want to follow that algorithm. That would work too. Nice! The reason I'm asking this is because I'm making a routine with grread where coordinate systems can be anywhere. Plus, if the origin of the UCS is not in plane with the object that you're modifying in the grread, it can screw up some. Which is why I just figured to use grread all related to WCS. It's also one reason why Lee's Align Text to Curve was acting up if the curve is not in plane with the UCS. I would understand it if your "VIEWDIR" is off because grread returns the coordinates of the mouse cursor on the construction plane, not the screen. You can try it here: TestAlign.dwg Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted April 19, 2020 Share Posted April 19, 2020 (edited) I have not checked, but my guess is the trans function is inconsistent here. The polar function measure the angle from Ox axis and trans function uses Arbitrary Axis Algorithm, which means you have no control over X axis. Instead of normal vector, I'd use a direction vector d, if possible. The result would be p+(unit d)*length Edit: Trans can be used, but not like in the examples above. The selected, or calculated, direction 1,0,0 should be also transformed from WCS to normal and the polar angle adjusted accordingly. Edited April 19, 2020 by Stefan BMR Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 21, 2020 Share Posted April 21, 2020 What about 1st principles using sin & cos work out X Y Z differences and then (setq p2 (mapcar '+ p1 (list X Y Z))) really have no idea with UCS Planes but makes sense. 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.