public void RotationByIdentityQuaternion() { var vector = new Vector3(3, 4, 5); var rotated = vector.RotatedBy(Quaternion.Identity); Assert.AreEqual(vector.x, rotated.x, Delta); Assert.AreEqual(vector.y, rotated.y, Delta); Assert.AreEqual(vector.z, rotated.z, Delta); }
public void RotationByNonZeroQuaternion() { var vector = new Vector3(3, 4, 5); var rotated = vector.RotatedBy(new Quaternion(0.5f, 0.5f, 0.5f, 0.5f)); Assert.AreEqual(5, rotated.x, Delta); Assert.AreEqual(3, rotated.y, Delta); Assert.AreEqual(4, rotated.z, Delta); }
public Ray ViewportPointToRay(float posX, float posY) { float dirY = posY * _tanHalfFoV; float dirX = posX * _tanHalfFoV * AspectRatio; var rayDirection = new Vector3(dirX, dirY, 1.0f); Vector3 rotatedDirection = rayDirection.RotatedBy(_rotation); return new Ray(_position, rotatedDirection); }