|
I am still pretty thick regarding trigonometry problems, and have a hard time figuring out the correct solution, despite my intermediate knowledge in vectors, transforms, matrixes, rotations, etc. What I basically need, is to always know the equivalent of 'vector3.up' in a local transform's rotation. The problem is that, since this transform's rotation is random, it's axes are most surely different from the world axes, and I'm at a loss about what kind of transforms I need apply to know the 'localvectorup' to determine 'where' is it's 'world.vector3.up' equivalent in local space. I know that my setting is ok because if I use it correctly rotates in the horizontal plane, regardless of how twisted its local transform is. The problem is, i don't know the direction of the rotation, nor its intensity, so I need to use to set its orientation in the horizontal plane based on another object's transform: what i basically need is to rotate 'mechanicalarm' around the 'vector3.up' regardless of mechanicalarm's local rotation and axes orientations. To clarify further: I don't need to find the arm's 'up' vector in respect to the world vector,which I can achieve through For a start, I think I need to find the vector which, in mechanicalarm's local coordinate space, is -always- parallel to the world's Vector3.up, regardless of mechanicalarm's rotation SIGH! So damn difficult :( Wonder if any of you trigonometry gurus out there can help me understand what are unity's correct functions to use to reach my goal. thanks.
(comments are locked)
|
|
I'm thinking it may be helpful to restate the actual problem, if only just for yourself. Some things that may be helpful: o You wrote you tested with o o Almost nothing takes local coords as input. Are you sure you need them? RotateAround takes the axis in World; DrawRay takes the dir as World; Are you sure you don't just want I am marking your answer as correct since it puts things in perspective, and clarifies the local and world coordinate issues with common transform questions. Thanks a lot for your time, I will now proceed to ask a clearer question.
Aug 11 '11 at 05:30 AM
roamcel
(comments are locked)
|
|
This seems to be it (world up in local coords): My test code, with comments on the logic behind it. I think a better way (for me) would have been to note that Keeping the locals and worlds straight is a real stumper. For example, the description of I thank you for your effort but If I Debug.drawray(mechanicalarm.position, worldUpInLocal) the line is indeed 'up', but only in respect to the local axes conversion, so it still rotates alongside the mechanical arm. As a matter of fact, the result is identical to newvector = mechanicalarm.InverseTransformDirection(mechanicalarm.up) and its drawray from mechanicalarm.position
Aug 10 '11 at 07:15 AM
roamcel
(comments are locked)
|

perhaps I need to create a new quaternion from mechanicarm.position, and vector3.up? but then what? I tried multiplying and subtracting from vector3.up but the vector I obtain is not constantly pointing up, but actually rotating along the arm...
I am now pretty sure that this can only be solved with a 4x4 matrix, since I clearly need to
1- extract the mechanicalarm's 'up' component
2- 'cross' it with the local upwards pointing vector
3- inject the modified 'up' component back into the mechanicalarms's rotation
Can this actually be done?