I'm trying to find out the point which is already rotated. To solve this I did a Rotation, save the position, set the previous position and return my position, like this:
Vector3 rotatePointAroundAxis(float angle ,Vector3 axis, Vector3 anchor)
{
Vector3 oldPosition = gameobject.transform.position;
gameobject.transform.RotateAround(gameobject.GetComponent<HingeJoint>().anchor, gameobject.GetComponent<HingeJoint>().axis, angle);
Vector3 newPosition = gameobject.transform.position;
gameobject.transform.position = oldPosition;
return newPosition;
}
I searched already. And I found very hard solutions. http://inside.mines.edu/fs_home/gmurray/ArbitraryAxisRotation/ - by the way i dont think I understand this, it seems like too much.
Is there any way to change that function to a "simple" one, so I don't need to rotate things forth and back to get the coordinates?
EDIT:
I believe tranform.RotateAround() takes the position and rotation from the transform parameters and calculates the solution and changes the current position and rotation of the gameobject.
So the solution should take 5 parameters:
- current position of the unrotated Object
- current rotation of the unrotated Object
- the point the Object should be able to pass
- the rotation axis
- the angle
and return 2 parameters:
- the rotated objects new rotation
- the rotated objects new position
Transform xform = gameobject.transform;
\$\endgroup\$ – 3Dave Nov 14 '16 at 14:00