From: Asaf Dafner Sent: Tuesday, March 05, 2002 2:11 AM > More specifically about rotations (or is it the math that i'm missing?): > I want to position a cylinder by using a function that receives two (x,y,z) points, > (so the cylinder is like a line stretching between these points). > Can anyone please provide some pointers/link/source extracts that would help me?
1. Points are P1 and P2 2. length of cylinder L = |P2 - P1| 3. desired unit vector along axis of cylinder V = (P2 - P1)/L 4. midpoint of line M = (P1 + P2)/2 5. Construct cylinder Shape3D cyl = new Shape3D . . . I forget what axis the Java 3D primitive Cylinder lines up on, say it's the X-axis, X. 6. Find rotation angle R = arccos(V dot X) 7. Find rotation axis S = X cross V; S = S/|S| 8. Construct translation Transform3D using midpoint M 9. Construct rotation Transform3D using axis S and angle R 10. Multiply them (R*M) and make a TransformGroup from the result. hth, Fred Klingener Thanks, Asaf. "Áö±Ô¼±" wrote: JeeGS> Hello...I am trying to obtain the same infomation as you are trying .....Can I get the same source code that you obtain? Thanks a lot... > Hi all, > I am rotating an object on the screen. It seems > to be rotating in a circular path, instead of rotating > on its own axis. > > In OpenGl, we can correct it by translating the object > to the origin and then apply transformations, and > again retranslate the object to its original place. > > Is this the way to do in Java3D. Can anyone give a > sample code. > > Thanks, > Sagar. > > __________________________________________________ > Do You Yahoo!? > Yahoo! Sports - sign up for Fantasy Baseball > http://sports.yahoo.com > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA3D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". > ____________________________________________________________________________ Çѹ̸£¿¡¼ ¹«·á À̸ÞÀÏÀ» ¹ÞÀ¸¼¼¿ä (http://mail.hanmir.com/) ¿ì¸®³¢¸® ÅëÇÏ´Â ÀÎÅÍ³Ý ¾ÆÁöÆ® Çѹ̸£ (http://www.hanmir.com/) =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". -- ------------------------------------------------- Asaf Dafner Short -but- Deep, Mainly Deep. Frontline PCB Solutions Phone : (972) 8-9322183 Ext. 148 Fax : (972) 8-9322186 email : [EMAIL PROTECTED] Je n'ai fait celle-ci plus longue que parce que je n'ai pas eu le loisir de la faire plus courte. - Pascal =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".