# Need a simple fast method for transforming a Vector3 around the origin

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?

The easiest way is using a Quaternion:

```Vector3 RotateAboutOrigin(Vector3 origin, Vector3 oldPos, float angle){
Quaternion rot = Quaternion.Euler(0, angle, 0); // calculate the rotation
Vector3 pos = oldPos - origin; // get a vector from origin to oldPos
pos = (rot * pos)+ origin; // rotate it by angle and add to origin
return pos;
}
```

It may be faster using AngleAxis instead of Euler:

```Vector3 RotateAboutOrigin(Vector3 origin, Vector3 oldPos, float angle){
Quaternion rot = Quaternion.AngleAxis(angle, Vector3.up); // calculate the rotation
Vector3 pos = oldPos - origin; // get a vector from origin to oldPos
pos = (rot * pos)+ origin; // rotate it by angle and add to origin
return pos;
}
```

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