Rotate by Rotation#
Math / Rotate by Rotation
Can Read
Cannot Write
Description#
Applies a rotation to a vector, turning the direction it points at
Parameters#
| Name | Description |
|---|---|
| Vector | The vector that is rotated |
| Rotation | The rotation applied to the vector |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Rotate by Rotation")]
[Category("Math/Rotate by Rotation")]
[Description("Applies a rotation to a vector, turning the direction it points at")]
[Image(typeof(IconQuaternion), ColorTheme.Type.Yellow, typeof(BadgeRotation))]
[Parameter("Vector", "The vector that is rotated")]
[Parameter("Rotation", "The rotation applied to the vector")]
[Keywords("Vector", "Quaternion", "Turn", "Spin", "Direction", "Transform", "Multiply")]
[Serializable]
public class TypeVector3MathRotateByQuaternion : TypeVector3
{
[SerializeField] private GetVector3 m_Vector = new GetVector3();
[SerializeField] private GetQuaternion m_Rotation = new GetQuaternion();
public override Vector3 GetPreview(GameObject source)
{
return this.m_Rotation.GetPreview(source) * this.m_Vector.GetPreview(source);
}
public override Vector3 Get(Args args)
{
return this.m_Rotation.Get(args) * this.m_Vector.Get(args);
}
public override string ToString()
{
return $"{this.m_Rotation} * {this.m_Vector}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}