#rotation around a point can be
1 messages · Page 1 of 1 (latest)
I asked gpt3 to do this:
using UnityEngine;
public class MatrixRotate : MonoBehaviour {
public Vector3 fixedPoint;
public Vector3 rotationAxis;
public float rotationAngle;
void Update ()
{
Matrix4x4 translation = Matrix4x4.Translate(fixedPoint);
Matrix4x4 rotation = Matrix4x4.Rotate(Quaternion.AngleAxis(rotationAngle, rotationAxis));
Matrix4x4 inverseTranslation = Matrix4x4.Translate(-fixedPoint);
transform.localPosition = translation * rotation * inverseTranslation * transform.localPosition;
}
}
Hey, where'd my post go
in a thread
can you see it?
I don't, so I'm not sure you're seeing the one I mean
here it is again
I put this to GPT3, and here's what it came up with:
public class MatrixRotate : MonoBehaviour {
public Vector3 fixedPoint;
public Vector3 rotationAxis;
public float rotationAngle;
void Update ()
{
Matrix4x4 translation = Matrix4x4.Translate(fixedPoint);
Matrix4x4 rotation = Matrix4x4.Rotate(Quaternion.AngleAxis(rotationAngle, rotationAxis));
Matrix4x4 inverseTranslation = Matrix4x4.Translate(-fixedPoint);
transform.localPosition = translation * rotation * inverseTranslation * transform.localPosition;
}
}