MSasu Posted April 9, 2014 Posted April 9, 2014 Since the analytical geometry is my weak spot (one of...) I would appreciate if someone may help me with the formula to rotate a point (P2) around another one (P1) in the vertical plan defined by them with a given angle (alfa) – I’m looking for the formula to get the result point (P3). I have to mention that I will use this in other programming language, so an AutoCAD based graphical solution is out of question. Thank you for attention! Quote
cwake Posted April 9, 2014 Posted April 9, 2014 Hi Mircea, my first thought when I looked at your question was: x3 = x1 + (x2-x1).cos(alfa) - (y2-y1).sin(alfa) y3 = y1 + (x2-x1).sin(alfa) + (y2-y1).cos(alfa) z3 = z1 That is a rotation around the z axis of point P1 using the AutoCAD convention that an anti-clockwise angle is positive and clockwise is negative. But I'm a bit worried that I'm misreading this... in the vertical plan defined by them Have I misunderstood the question? Quote
MSasu Posted April 9, 2014 Author Posted April 9, 2014 Clint, thank you for your attention! I'm afraid that you misunderstood the question, indeed. I will try to post a picture. Quote
cwake Posted April 9, 2014 Posted April 9, 2014 If I understand more correctly now Mircea, I think the easiest thing would be to follow the maths in Lee Mac's LM:Rotate3D function under 3D transformations. If you can convert it and the associated matrix multiplication functions to the other programming language it should do the trick. http://www.lee-mac.com/matrixtransformationfunctions.html You would need to provide the normal unit vector to rotate around, defined in Lee's function by u, ux, uy & uz. I understand that the rotation you want to achieve is always in the vertical plane? So to get your normal unit vector you would replace the maths done by this line of code (mapcar 'set '(ux uy uz) (setq u (unit (mapcar '- p2 p1)))) with (mapcar 'set '(ux uy uz) (setq u (unit (list (- y2 y1) (- x1 x2) 0)))) where Point P1 is defined by '(x1 y1 z1) and Point P2 is defined by '(x2 y2 z2) Quote
BIGAL Posted April 10, 2014 Posted April 10, 2014 Looking at the image you need a few more angles not just alpha, if I understand correct that alpha is an angle in a tilted plane, in autocad using UCS its pretty simple it can be solved. I think you need more angles beta & gamma=vert & horiz. Maybe as a start have a google for surveying formula for spheriods if you think of it as a pt on a ball then someone probably has done this. A 3pt wedge formula ? plane cutting sphere ? wheres my google. Quote
Stefan BMR Posted April 10, 2014 Posted April 10, 2014 Salut Mircea You need to define an axis of rotation. In Autocad, this is made by picking 2 points (see the old rotate3d command). So you have a point p to be rotated, an origin and a direction. Now you can apply Rodrigues' rotation formula. I've write a sample for you. In the final formula, "x" denote cross-product. 3D-rot.pdf Quote
cwake Posted April 10, 2014 Posted April 10, 2014 You need to define an axis of rotation. Now you can apply Rodrigues' rotation formula. 1+ I agree with Stefan, Mircea. If it helps to avoid any confusion, Lee's function that I referred to is doing that in the form as mentioned in that Wikipedia article Rodrigues' rotation formula Quote
Stefan BMR Posted April 10, 2014 Posted April 10, 2014 Mircea, here is another solution. It is just for testing, but if you want to develop this idea further, there are some things that you should consider: - the normal vector to plane could be in a direction or in the other, so there are 2 possible answers. You can make a convention on what is positive and negative rotation. - the atan function returns a number in the interval -pi/2...pi/2, but in my solution the true angle is required, in the interval 0...2pi. (that is a.z in attachment). This can be done by studying the relative position of selected points. 3D-rot II.pdf Quote
MSasu Posted April 11, 2014 Author Posted April 11, 2014 Thank you so much Gentlemen for your solutions! I will review these and come back to you. Quote
MSasu Posted April 15, 2014 Author Posted April 15, 2014 Stefan, the algebric solution works a treat; thank you! Multumesc! 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.