I have a Vector3 representing an arbitrary point on the ground (Y=0).
I have a float representing a euler angle.
Imagine the point is a speck of dust on a vinyl record, and the angle is an angle to rotate the disc.
The spindle is at the 0,0,0. Even better if I could place the spindle anywhere.
I want to get the new Vector3 position of the speck.
E.g. the speck is at -3,0,1 and it rotates 90, it becomes 1,0,3. (It won’t be multiples of 90, but any number)
Something like:
Vector3 oldPosition = new Vector3( -3,0,1 );
Vector3 newPosition = Speck.RotateAboutOrigin( oldPosition, 90 );
// Should return (1,0,3)
Do I have to get into quaternions or matrices or can it be done more simply?
if you make the arbitrary point an empty, then make the speck another empty. just make the speck a child of the arbitrary point. that way you can rotate the arbitrary point all you want to get the speck in the right place.
and if you really need the speck not as a child, you just use like a temp child empty to get its new world co ordinates. something like this (on arbitrary point)
`
public Transform speckPosition = Vector3;
public Transform speckPrefab;
void Update() {
yRotation += Input.GetAxis("Horizontal");
transform.eulerAngles = new Vector3(0, yRotation, 0);
Instantiate(speckPrefab, speck.position , speck.rotation) as Transform;
}
`
i havent tested this code or anything either. but doing it this way u should get what i think you want
That would work, but I was looking for a way using pure maths...
Absolutely perfectamundo! Thanks!
– quoxel