Skip to content

Instantly share code, notes, and snippets.

@skyburchard
Created May 12, 2020 04:35
Show Gist options
  • Save skyburchard/b3afc70c06d06d898d8c7972b830a1ec to your computer and use it in GitHub Desktop.
Save skyburchard/b3afc70c06d06d898d8c7972b830a1ec to your computer and use it in GitHub Desktop.
////////////////////////////////////////////////////////
// rotate a point around another point using quaternions
// set quaterion by vector
var quat = Quaternion.LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);
// set quaternion by angle
var quat = Quaternion.AngleAxis(float angle, Vector3 axis);
// rotate around pivit point
Vector3 RotateAroundPoint(Vector3 point, Vector3 pivot, Quaternion angle)
{
return angle * ( point - pivot) + pivot;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment