Empeld
Empeld plugin documentation.
pluginbase.Helpers.Coords.Rotation2d Struct Reference

Rotation XZ; In radians More...

Public Member Functions

 Rotation2d (double x, double z)
 
Rotation2d TurnTo (Rotation2d toRot)
 Calculates the shortest turn-distance from this rotation to another one. (Not resulting rotation, but how much we have to rotate and which direction) eg. if this rotation is 0, and the other rotation is 7, it should compute the shortest turn to be 0.72 More...
 
Rotation2d TurnToResult (Rotation2d toRot)
 Calculates the resulting rotation of computing the shortest turn two a given rotation More...
 
void Normalize ()
 Normalize this back into the 0-2pi range More...
 
Rotation2d Normalized ()
 Normalize the current rotation in the 0-2pi range and return the result More...
 
override string ToString ()
 

Static Public Member Functions

static Rotation2d FromDegrees (double x, double z)
 
static Rotation2d FromDirectionZUp (Vector3d dir)
 
static implicit operator Vector2d (Rotation2d rot)
 
static operator Rotation2d (Vector2d vec)
 
static implicit operator Rotation2d (Rotation2 rot)
 
static operator Rotation2 (Rotation2d rot)
 
static Rotation2d operator+ (Rotation2d a, Rotation2d b)
 
static Rotation2d operator- (Rotation2d a, Rotation2d b)
 
static Rotation2d operator* (Rotation2d a, Rotation2d b)
 
static Rotation2d operator/ (Rotation2d a, Rotation2d b)
 
static Rotation2d operator* (Rotation2d a, double v)
 
static Rotation2d operator* (double v, Rotation2d b)
 

Public Attributes

double X
 
double Z
 

Static Public Attributes

static readonly Rotation2d Zero = new Rotation2d(0.0, 0.0)
 
static readonly Rotation2d UnitX = new Rotation2d(1.0, 0.0)
 
static readonly Rotation2d UnitZ = new Rotation2d(0.0, 1.0)
 

Properties

double DegreesX [get]
 
double DegreesZ [get]
 
Vector3d Vector [get]
 
Vector3d VectorZAxis [get]
 

Detailed Description

Rotation XZ; In radians

Constructor & Destructor Documentation

◆ Rotation2d()

pluginbase.Helpers.Coords.Rotation2d.Rotation2d ( double  x,
double  z 
)
17  {
18  X = x;
19  Z = z;
20  }
double X
Definition: Rotation2d.cs:12
double Z
Definition: Rotation2d.cs:12

Member Function Documentation

◆ FromDegrees()

static Rotation2d pluginbase.Helpers.Coords.Rotation2d.FromDegrees ( double  x,
double  z 
)
static
23  {
24  return new Rotation2d( MExt.DegreeToRadian(x), MExt.DegreeToRadian(z) );
25  }
static float DegreeToRadian(float degree)
Degrees to radian.
Definition: MathExtensions.cs:286
Math extensions
Definition: MathExtensions.cs:7
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ FromDirectionZUp()

static Rotation2d pluginbase.Helpers.Coords.Rotation2d.FromDirectionZUp ( Vector3d  dir)
static
28  {
29  return new Rotation2d(
30  Math.Asin(dir.Z),
31  Math.Atan2(dir.X, dir.Y)
32  );
33  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ Normalize()

void pluginbase.Helpers.Coords.Rotation2d.Normalize ( )

Normalize this back into the 0-2pi range

112  {
113  this.X = MExt.FloatRemainder(this.X, MathHelper.TwoPi);
114  this.Z = MExt.FloatRemainder(this.Z, MathHelper.TwoPi);
115  }
double X
Definition: Rotation2d.cs:12
Math extensions
Definition: MathExtensions.cs:7
static float FloatRemainder(float val, float div)
Get the remainder of two floats divided by each other i.e. 11/4, has a remainder of 3; or 4 / 1...
Definition: MathExtensions.cs:101
double Z
Definition: Rotation2d.cs:12

◆ Normalized()

Rotation2d pluginbase.Helpers.Coords.Rotation2d.Normalized ( )

Normalize the current rotation in the 0-2pi range and return the result

Returns
The normalized.
122  {
123  var rot = new Rotation2d(this.X, this.Z);
124  rot.Normalize();
125  return rot;
126  }
double X
Definition: Rotation2d.cs:12
double Z
Definition: Rotation2d.cs:12
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ operator Rotation2()

static pluginbase.Helpers.Coords.Rotation2d.operator Rotation2 ( Rotation2d  rot)
explicitstatic
148  {
149  return new Rotation2((float)rot.X, (float)rot.Z);
150  }

◆ operator Rotation2d() [1/2]

static pluginbase.Helpers.Coords.Rotation2d.operator Rotation2d ( Vector2d  vec)
explicitstatic
138  {
139  return new Rotation2d(vec.X, vec.Y);
140  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ operator Rotation2d() [2/2]

static implicit pluginbase.Helpers.Coords.Rotation2d.operator Rotation2d ( Rotation2  rot)
static
143  {
144  return new Rotation2d(rot.X, rot.Z);
145  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ operator Vector2d()

static implicit pluginbase.Helpers.Coords.Rotation2d.operator Vector2d ( Rotation2d  rot)
static
133  {
134  return new Vector2d(rot.X, rot.Z);
135  }

◆ operator*() [1/3]

static Rotation2d pluginbase.Helpers.Coords.Rotation2d.operator* ( Rotation2d  a,
Rotation2d  b 
)
static
165  {
166  return new Rotation2d(a.X * b.X, a.Z * b.Z);
167  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ operator*() [2/3]

static Rotation2d pluginbase.Helpers.Coords.Rotation2d.operator* ( Rotation2d  a,
double  v 
)
static
175  {
176  return new Rotation2d(a.X*v, a.Z*v);
177  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ operator*() [3/3]

static Rotation2d pluginbase.Helpers.Coords.Rotation2d.operator* ( double  v,
Rotation2d  b 
)
static
180  {
181  return new Rotation2d(v*b.X, v*b.Z);
182  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ operator+()

static Rotation2d pluginbase.Helpers.Coords.Rotation2d.operator+ ( Rotation2d  a,
Rotation2d  b 
)
static
155  {
156  return new Rotation2d(a.X + b.X, a.Z + b.Z);
157  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ operator-()

static Rotation2d pluginbase.Helpers.Coords.Rotation2d.operator- ( Rotation2d  a,
Rotation2d  b 
)
static
160  {
161  return new Rotation2d(a.X - b.X, a.Z - b.Z);
162  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ operator/()

static Rotation2d pluginbase.Helpers.Coords.Rotation2d.operator/ ( Rotation2d  a,
Rotation2d  b 
)
static
170  {
171  return new Rotation2d(a.X/b.X, a.Z/b.Z);
172  }
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ ToString()

override string pluginbase.Helpers.Coords.Rotation2d.ToString ( )
188  {
189  return string.Format("({0}, {1})", X, Z);
190  }
double X
Definition: Rotation2d.cs:12
double Z
Definition: Rotation2d.cs:12

◆ TurnTo()

Rotation2d pluginbase.Helpers.Coords.Rotation2d.TurnTo ( Rotation2d  toRot)

Calculates the shortest turn-distance from this rotation to another one. (Not resulting rotation, but how much we have to rotate and which direction) eg. if this rotation is 0, and the other rotation is 7, it should compute the shortest turn to be 0.72

Returns
The turn.
Parameters
toRotTo rot.
54  {
55  const float ThreePi = 3f * MathHelper.Pi;
56  var diff = toRot.Normalized() - this.Normalized();
57  return new Rotation2d(
58  MExt.FloatRemainder(diff.X + ThreePi, MathHelper.TwoPi) - MathHelper.Pi,
59  MExt.FloatRemainder(diff.Z + ThreePi, MathHelper.TwoPi) - MathHelper.Pi);
60  }
Math extensions
Definition: MathExtensions.cs:7
static float FloatRemainder(float val, float div)
Get the remainder of two floats divided by each other i.e. 11/4, has a remainder of 3; or 4 / 1...
Definition: MathExtensions.cs:101
Rotation2d Normalized()
Normalize the current rotation in the 0-2pi range and return the result
Definition: Rotation2d.cs:121
Rotation2d(double x, double z)
Definition: Rotation2d.cs:16

◆ TurnToResult()

Rotation2d pluginbase.Helpers.Coords.Rotation2d.TurnToResult ( Rotation2d  toRot)

Calculates the resulting rotation of computing the shortest turn two a given rotation

Returns
The rotation.
Parameters
toRotTo rot.
68  {
69  return this + this.TurnTo(toRot);
70  }
Rotation2d TurnTo(Rotation2d toRot)
Calculates the shortest turn-distance from this rotation to another one. (Not resulting rotation...
Definition: Rotation2d.cs:53

Member Data Documentation

◆ UnitX

readonly Rotation2d pluginbase.Helpers.Coords.Rotation2d.UnitX = new Rotation2d(1.0, 0.0)
static

◆ UnitZ

readonly Rotation2d pluginbase.Helpers.Coords.Rotation2d.UnitZ = new Rotation2d(0.0, 1.0)
static

◆ X

double pluginbase.Helpers.Coords.Rotation2d.X

◆ Z

double pluginbase.Helpers.Coords.Rotation2d.Z

◆ Zero

readonly Rotation2d pluginbase.Helpers.Coords.Rotation2d.Zero = new Rotation2d(0.0, 0.0)
static

Property Documentation

◆ DegreesX

double pluginbase.Helpers.Coords.Rotation2d.DegreesX
get

◆ DegreesZ

double pluginbase.Helpers.Coords.Rotation2d.DegreesZ
get

◆ Vector

Vector3d pluginbase.Helpers.Coords.Rotation2d.Vector
get

◆ VectorZAxis

Vector3d pluginbase.Helpers.Coords.Rotation2d.VectorZAxis
get

The documentation for this struct was generated from the following file: