Skip to main content
added 51 characters in body
Source Link
Foggzie
  • 1.2k
  • 8
  • 13

The concept of a "rotation" is represented by a Quaternion. These are built into Unity and there's no need for you to understand the math in that link you posted.

To create a rotation from an angle & axis, use Quaternion.AngleAxis. Once you have it, you can simply multiply it by the Vector3 you're trying to rotate. Your function would look like this:

Vector3 rotatePointAroundAxis(Vector3 point, float angle, Vector3 axis)
{
    Quaternion q = Quaternion.AngleAxis(angle, axis);
    return q * point; //Note: q must be first (point * q wouldn't compile)
}

The concept of a "rotation" is represented by a Quaternion. These are built into Unity and there's no need for you to understand the math in that link you posted.

To create a rotation from an angle & axis, use Quaternion.AngleAxis. Once you have it, you can simply multiply it by the Vector3 you're trying to rotate. Your function would look like this:

Vector3 rotatePointAroundAxis(Vector3 point, float angle, Vector3 axis)
{
    Quaternion q = Quaternion.AngleAxis(angle, axis);
    return q * point;
}

The concept of a "rotation" is represented by a Quaternion. These are built into Unity and there's no need for you to understand the math in that link you posted.

To create a rotation from an angle & axis, use Quaternion.AngleAxis. Once you have it, you can simply multiply it by the Vector3 you're trying to rotate. Your function would look like this:

Vector3 rotatePointAroundAxis(Vector3 point, float angle, Vector3 axis)
{
    Quaternion q = Quaternion.AngleAxis(angle, axis);
    return q * point; //Note: q must be first (point * q wouldn't compile)
}
Source Link
Foggzie
  • 1.2k
  • 8
  • 13

The concept of a "rotation" is represented by a Quaternion. These are built into Unity and there's no need for you to understand the math in that link you posted.

To create a rotation from an angle & axis, use Quaternion.AngleAxis. Once you have it, you can simply multiply it by the Vector3 you're trying to rotate. Your function would look like this:

Vector3 rotatePointAroundAxis(Vector3 point, float angle, Vector3 axis)
{
    Quaternion q = Quaternion.AngleAxis(angle, axis);
    return q * point;
}