public sealed struct Rotation
Represents a Quaternion rotation. Can be interpreted as a direction unit vector (x,y,z) + rotation around the direction vector (w) which represents the up direction. Unlike `Angles`, this cannot store multiple revolutions around an axis.
Related Guides
Broader workflow and conceptual references connected to this API.
If you want a specific file/asset type to have a custom Thumbnail/Inspector Preview, you can simply create an AssetPreview. An AssetPreview initializes a SceneWorld and SceneCamera, rendering the Camera to the Preview output, so all you need to do is populate it and/or position the Camera to your liking.
You can create your own editor tool to help you create your game. Your tool needs to be created in an editor project.
A Vector is just a set of numbers that describe a position or a direction in space.
This section needs to be rewritten with an explanation of all the code, libraries, etc.
The decal component draws a decal in the game world.
S&box uses a scene system to create games. We feel this is the easiest system for people to pick up, while still being powerful.
Constructors
Showing 3 constructors
No results match this filter.
Methods
Showing 30 methods
public bool AlmostEqual(Rotation r, float delta = 1E-05)
Returns true if we're nearly equal to the passed rotation. Checks if each component is within a threshold, and handles the fact that there are two ways to represent the same rotation as a quaternion.
Parameters
r: The value to compare withdelta: Per-component threshold. Default: 1E-05
Returns
True if nearly equal
public float Angle()
Returns the turn length of this rotation (from identity) in degrees
public static Rotation Difference(Rotation from, Rotation to)
Returns the difference between two rotations, as a rotation
public float Distance(Rotation to)
The degree angular distance between this rotation and the target
public static Rotation FromAxis(Vector3 axis, float degrees)
Create from angle and an axis
Note
`axis` vector must be normalized before calling this method or the resulting `Rotation` will be incorrect.
public static Rotation FromPitch(float pitch)
Create a Rotation (quaternion) from pitch (degrees)
public static Rotation FromRoll(float roll)
Create a Rotation (quaternion) from roll (degrees)
public static Rotation FromToRotation(Vector3 fromDirection, Vector3 toDirection)
Returns a Rotation that rotates from one direction to another.
public static Rotation FromYaw(float yaw)
Create a Rotation (quaternion) from yaw (degrees)
public static Rotation Lerp(Rotation a, Rotation b, float frac, bool clamp = True)
Perform a linear interpolation from a to b by given amount.
Parameters
clamp: Default: True
public Rotation LerpTo(Rotation target, float frac, bool clamp = True)
Perform a linear interpolation from this rotation to a target rotation by given amount.
Parameters
clamp: Default: True
public float Pitch()
Return this Rotation pitch
public float Roll()
Return this Rotation roll
public Rotation RotateAroundAxis(Vector3 axis, float degrees)
A convenience function that rotates this rotation around a given axis given amount of degrees
Note
`axis` vector must be normalized before calling this method or the resulting `Rotation` will be incorrect.
public static Rotation Slerp(Rotation a, Rotation b, float amount, bool clamp = True)
Perform a spherical interpolation from a to b by given amount.
Parameters
clamp: Default: True
public Rotation SlerpTo(Rotation target, float frac, bool clamp = True)
Perform a spherical interpolation from this rotation to a target rotation by given amount.
Parameters
clamp: Default: True
public static Rotation SmoothDamp(Rotation current, Rotation target, Vector3 velocity, float smoothTime, float deltaTime)
Smoothly move towards the target rotation
public float Yaw()
Return this Rotation yaw
No results match this filter.
Properties
Showing 14 properties
public Rotation Rotation.Conjugate { get; set; }
Returns conjugate of this rotation, meaning the X Y and Z components are negated.
public Rotation Rotation.Normal { get; set; }
Divides each component of the rotation by its length, normalizing the rotation.
public float Rotation.w { get; set; }
The W component of this rotation (rotation around the normal defined by X,Y,Z components).
public float Rotation.x { get; set; }
The X component of this rotation.
public float Rotation.y { get; set; }
The Y component of this rotation.
public float Rotation.z { get; set; }
The Z component of this rotation.
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | global |
| Type | class |
| Assembly | Sandbox.System |
| Doc ID | T:Rotation |