AC3D Forums Get Rotation of a Group or Object
 User Name Remember Me? Password
 Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 Thread Tools Display Modes
 12th June 2006, 09:42 PM #1 conzar Member Advanced member     Join Date: May 2006 Posts: 36 Get Rotation of a Group or Object Is it possible to get the rotation of an object relative to the origin? Simular to the get_centre function. For example, say you have 2 boxes in a group. You rotate that group on the x-axis by pi. Is there a way that I can get the rotation about the x,y,z axis? So for the example here I should get rotation (3.14,0,0). If we rotate the group again in the same direction on the same axis by pi again, then we should get [0,0,0].
 13th June 2006, 04:05 AM #2 Andy Administrator Professional user     Join Date: Jun 2003 Posts: 4,382 Re: Get Rotation of a Group or Object Sorry, this is not currently possible since the vertices are rotated in the global space.
 13th June 2006, 08:35 PM #3 conzar Member Advanced member     Join Date: May 2006 Posts: 36 Re: Get Rotation of a Group or Object Ok, I think its possible to do this ... check my math and let me know what u think. Have a group that is to be copied. The copies of the group are to be translated and rotated. I think it is possible to get the rotation of the groups by doing the following: * translating the copy back to the origin (where the location of the original is) * calculate the rotation of the x,y,z axis via the location of vertaces. -> ie, take the first vertex from the copy and the first vertex from the original and apply the math below The above math is derived from the information found at the link below. http://www.tpub.com/math2/5.htm So what do you think? Does this sound feasible? I need functions that do the followingtranslate group to origin Get a specific vertex in a group (the first one) arc tan function I know there are functions available in the ac3d headers that do the first 2. So can I use the Math.h functions to get arc tan or is there something available in the headers for that? (Update) I've answered my own question here - I just tried atan and Math.h works! Last edited by conzar; 13th June 2006 at 08:55 PM.
 21st June 2006, 11:11 PM #4 conzar Member Advanced member     Join Date: May 2006 Posts: 36 Re: Get Rotation of a Group or Object Arg. Looks like the math above is flawed b/c one doesn't know in which order the object was rotated. So I have come up w/ another possible solution. Here it is: Create a plugin that records the rotations applied to an object as well as which order the rotations were applied. I think this is a simple solution; none-the-less, its a solution. I'll report back in a few days ...
 25th June 2006, 04:19 PM #5 conzar Member Advanced member     Join Date: May 2006 Posts: 36 Re: Get Rotation of a Group or Object Hey. So I can't seem to find a function call to rotate an object. The only functions I found that seemed close are listed below. Code: ```set_global_matrix_rotate(float rx, float ry, float rz) void rotate_object(ACObject *ob)``` What I would like to have is something like Code: `ac_rotate_object(ACObject *ob, float rx, float ry, float rz)` Is there anything like that? Thanks
 7th September 2006, 06:45 AM #6 PerFnurt Member Expert member   Join Date: Aug 2003 Location: Eslöv, Sweden Posts: 93 Re: Get Rotation of a Group or Object Can't you use the 2 function calls in the way you're requesting? void my_rotate_object(ACObject *ob, float rx, float ry, float rz) { set_global_matrix_rotate(rx,ry,rz); rotate_object(ob); recordRotationSomehow(rx,ry,rz); } __________________ /Per www.perfnurt.se Last edited by PerFnurt; 7th September 2006 at 10:24 AM.
 26th September 2006, 09:14 AM #7 conzar Member Advanced member     Join Date: May 2006 Posts: 36 Re: Get Rotation of a Group or Object Hot dang your right. Just saw your post today ... so I'll try that tonight. Thanks
 26th September 2006, 08:54 PM #8 conzar Member Advanced member     Join Date: May 2006 Posts: 36 Re: Get Rotation of a Group or Object Humm. Seems like the above code rotates an object about the origin. How would I rotate it about the center of the object? I would like the same functionality as the rotate buttons on the left side bar. Thanks.
26th September 2006, 09:38 PM   #9
Dennis
Senior Member
Professional user

Join Date: Jul 2003
Posts: 899
Re: Get Rotation of a Group or Object

Quote:
 Originally Posted by conzar Humm. Seems like the above code rotates an object about the origin. How would I rotate it about the center of the object? I would like the same functionality as the rotate buttons on the left side bar.
You'll want to move the object to the origin, rotate it, then move it back to its original position. The rotation function exposed through the SDK doesn't handle the translation part of the equation.

Alternatively, you could call the code that AC3D uses when you use the left side bar rotate function. Check out the ac3d.tcl file in the "scripts" directory and look for "ac3d rotate_axis_angle". This snippet might help:

Code:
```// Specify axis where 0 = x, 1 = y, 2 = z
int axis = 1;
float degrees = 90.0f;
tcl_command( "ac3d rotate_axis_angle %d %g", axis, degrees );```
The above code should rotate the selected geometry 90 degrees around the Y axis, relative to the object/selection center. Note that this is off the cuff and untested.

Good luck

 27th September 2006, 01:56 PM #10 conzar Member Advanced member     Join Date: May 2006 Posts: 36 Re: Get Rotation of a Group or Object Yep. That did the trick. Thanks!!!!

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules

All times are GMT -4. The time now is 09:10 PM.

 Archive - Top

AC3D Forum
(C) Inivis Limited 2020