コード例 #1
0
 public double AngleTo(Vector2d to)
 {
     return(Mathd.Atan2(Cross(to), Dot(to)));
 }
コード例 #2
0
 public bool IsNormalized()
 {
     return(Mathd.Abs(LengthSquared() - 1.0f) < Mathd.Epsilon);
 }
コード例 #3
0
 /// <summary>
 /// Returns an AABBd with equivalent position and size, modified so that
 /// the most-negative corner is the origin and the size is positive.
 /// </summary>
 /// <returns>The modified AABBd.</returns>
 public AABBd Abs()
 {
     Vector3d end = End;
     Vector3d topLeft = new Vector3d(Mathd.Min(_position.x, end.x), Mathd.Min(_position.y, end.y), Mathd.Min(_position.z, end.z));
     return new AABBd(topLeft, _size.Abs());
 }
コード例 #4
0
ファイル: Vector3d.cs プロジェクト: manaorb/GodotExtraMath
 /// <summary>
 /// Returns true if this vector and `other` are approximately equal, by running
 /// <see cref="Mathd.IsEqualApprox(double, double)"/> on each component.
 /// </summary>
 /// <param name="other">The other vector to compare.</param>
 /// <returns>Whether or not the vectors are approximately equal.</returns>
 public bool IsEqualApprox(Vector3d other)
 {
     return(Mathd.IsEqualApprox(x, other.x) && Mathd.IsEqualApprox(y, other.y) && Mathd.IsEqualApprox(z, other.z));
 }
コード例 #5
0
 public double DistanceTo(Vector2d to)
 {
     return(Mathd.Sqrt((x - to.x) * (x - to.x) + (y - to.y) * (y - to.y)));
 }
コード例 #6
0
ファイル: Vector3d.cs プロジェクト: manaorb/GodotExtraMath
 /// <summary>
 /// Returns the unsigned minimum angle to the given vector, in radians.
 /// </summary>
 /// <param name="to">The other vector to compare this vector to.</param>
 /// <returns>The unsigned angle between the two vectors, in radians.</returns>
 public double AngleTo(Vector3d to)
 {
     return(Mathd.Atan2(Cross(to).Length(), Dot(to)));
 }
コード例 #7
0
ファイル: Vector3d.cs プロジェクト: manaorb/GodotExtraMath
 /// <summary>
 /// Returns a new vector with all components rounded down (towards negative infinity).
 /// </summary>
 /// <returns>A vector with <see cref="Mathd.Floor"/> called on each component.</returns>
 public Vector3d Floor()
 {
     return(new Vector3d(Mathd.Floor(x), Mathd.Floor(y), Mathd.Floor(z)));
 }
コード例 #8
0
ファイル: Planed.cs プロジェクト: manaorb/GodotExtraMath
        /// <summary>
        /// Returns true if point is inside the plane.
        /// Comparison uses a custom minimum epsilon threshold.
        /// </summary>
        /// <param name="point">The point to check.</param>
        /// <param name="epsilon">The tolerance threshold.</param>
        /// <returns>A bool for whether or not the plane has the point.</returns>
        public bool HasPoint(Vector3d point, double epsilon = Mathd.Epsilon)
        {
            double dist = _normal.Dot(point) - D;

            return(Mathd.Abs(dist) <= epsilon);
        }
コード例 #9
0
ファイル: Planed.cs プロジェクト: manaorb/GodotExtraMath
 /// <summary>
 /// Returns true if this plane and `other` are approximately equal, by running
 /// <see cref="Mathd.IsEqualApprox(double, double)"/> on each component.
 /// </summary>
 /// <param name="other">The other plane to compare.</param>
 /// <returns>Whether or not the planes are approximately equal.</returns>
 public bool IsEqualApprox(Planed other)
 {
     return(_normal.IsEqualApprox(other._normal) && Mathd.IsEqualApprox(D, other.D));
 }
コード例 #10
0
 public Vector4d Round()
 {
     return(new Vector4d(Mathd.Round(x), Mathd.Round(y), Mathd.Round(z), Mathd.Round(w)));
 }
コード例 #11
0
 public bool Equals(Vector4d other)
 {
     return(Mathd.IsEqualApprox(x, other.x) && Mathd.IsEqualApprox(y, other.y) && Mathd.IsEqualApprox(z, other.z) && Mathd.IsEqualApprox(w, other.w));
 }
コード例 #12
0
 public Vector4d Floor()
 {
     return(new Vector4d(Mathd.Floor(x), Mathd.Floor(y), Mathd.Floor(z), Mathd.Floor(w)));
 }
コード例 #13
0
 public Vector4d Ceil()
 {
     return(new Vector4d(Mathd.Ceil(x), Mathd.Ceil(y), Mathd.Ceil(z), Mathd.Ceil(w)));
 }
コード例 #14
0
 public Vector4d Abs()
 {
     return(new Vector4d(Mathd.Abs(x), Mathd.Abs(y), Mathd.Abs(z), Mathd.Abs(w)));
 }
コード例 #15
0
 public double AngleToPoint(Vector2d to)
 {
     return(Mathd.Atan2(y - to.y, x - to.x));
 }
コード例 #16
0
        public Vector2d Rotated(double phi)
        {
            double rads = Angle() + phi;

            return(new Vector2d(Mathd.Cos(rads), Mathd.Sin(rads)) * Length());
        }
コード例 #17
0
ファイル: Vector3d.cs プロジェクト: manaorb/GodotExtraMath
 /// <summary>
 /// Returns a new vector with all components in absolute values (i.e. positive).
 /// </summary>
 /// <returns>A vector with <see cref="Mathd.Abs(double)"/> called on each component.</returns>
 public Vector3d Abs()
 {
     return(new Vector3d(Mathd.Abs(x), Mathd.Abs(y), Mathd.Abs(z)));
 }
コード例 #18
0
 public Vector2d Round()
 {
     return(new Vector2d(Mathd.Round(x), Mathd.Round(y)));
 }
コード例 #19
0
ファイル: Vector3d.cs プロジェクト: manaorb/GodotExtraMath
 /// <summary>
 /// Returns a new vector with all components rounded up (towards positive infinity).
 /// </summary>
 /// <returns>A vector with <see cref="Mathd.Ceil"/> called on each component.</returns>
 public Vector3d Ceil()
 {
     return(new Vector3d(Mathd.Ceil(x), Mathd.Ceil(y), Mathd.Ceil(z)));
 }
コード例 #20
0
 public Vector2d Snapped(Vector2d by)
 {
     return(new Vector2d(Mathd.Stepify(x, by.x), Mathd.Stepify(y, by.y)));
 }
コード例 #21
0
ファイル: Vector3d.cs プロジェクト: manaorb/GodotExtraMath
 /// <summary>
 /// Returns this vector with all components rounded to the nearest integer,
 /// with halfway cases rounded towards the nearest multiple of two.
 /// </summary>
 /// <returns>The rounded vector.</returns>
 public Vector3d Round()
 {
     return(new Vector3d(Mathd.Round(x), Mathd.Round(y), Mathd.Round(z)));
 }
コード例 #22
0
 public bool Equals(Vector2d other)
 {
     return(Mathd.IsEqualApprox(x, other.x) && Mathd.IsEqualApprox(y, other.y));
 }
コード例 #23
0
 public Vector2d Ceil()
 {
     return(new Vector2d(Mathd.Ceil(x), Mathd.Ceil(y)));
 }
コード例 #24
0
 public Vector2d Abs()
 {
     return(new Vector2d(Mathd.Abs(x), Mathd.Abs(y)));
 }
コード例 #25
0
 public Vector2d Floor()
 {
     return(new Vector2d(Mathd.Floor(x), Mathd.Floor(y)));
 }
コード例 #26
0
 public double Angle()
 {
     return(Mathd.Atan2(y, x));
 }
コード例 #27
0
 public double Length()
 {
     return(Mathd.Sqrt(x * x + y * y));
 }
コード例 #28
0
 public bool Equals(Planed other)
 {
     return(_normal == other._normal && Mathd.IsEqualApprox(D, other.D));
 }