Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
01-06-2006 08:21
If you have a prim cube and the xyz coordinates for one corner on the upper edge and the farthest corner on the bottom edge, what method would you use to calculate the offset between these two point as these two point as the cube is rotated around it z axis though 360 degrees? Thanks in advance, Mod
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
01-06-2006 10:11
Seems to me like you'd want to subtract the center of the cube from these points, multiply by the rotation in question, and then add back on the center:
<code>
vector topcorner=<1,2,3>; vector bottomcorner=<-1,-2,-3>; vector center=<0.5,0.5,0.5>;
rotation rot=<whatever>;
vector newtopcorner = (topcorner - center) * rot + center;
// etc </code>
I'm not sure what you're really after, though.
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
01-06-2006 10:58
I agree with lex, your question isn't very clear. Are you after a general expression for a circle (which is what it sounds like you're drawing), a way to calculate the positions of the long diagonal of a cube at any rotation? Something else?
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
Clarificantion, hopefully
01-06-2006 11:27
Sorry for being unclear. What I am to understand is how calculate the changes in coordinates of the two points as the prim is rotated through a complete circle and to be able to calculate the coordinates of one from the coordinates of the other, or by known the current rotation of the prim. This would be simple in terms of degrees and distance I only had to calculate points on the circumference of a circle at each end of a cylinder, but I cannot get my mind around how that would be expressed in coordinates.
Mod
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
01-06-2006 11:47
Hmm, ok.
llGetPos() returns the rotational centre of the prim. If you know the offset vectors o1 and o2for the points you want to calculate then the new relative positions are o1*llGetRot() and o2*llGetRot() (may need to be llGetLocalRot() depending on your application) - this is why we work in these funny rotations.
The sim co-ordinates are then new relative positions+llGetPos().
If you don't know the offset vectors, only actual positions at ZERO_ROTATION then Lex's code will help you calculate that.
If the object is likely to be resized and/or reshaped you can use llGetScale() and llGetPrimitiveParams() to try and cover the bases, although some of the calculations will be a nightmare I suspect if you can reshape (cylinders don't have vertices etc....)
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
Thanks to all again
01-06-2006 14:46
Digesting your suggestions and explanaiton will help me begin to undersand the why and how of the problem. I appreciate it much and my mind gets some needed exercise.
Mod
|