Esempio n. 1
0
 /// <summary>
 /// Performs a 3-dimensional rotation on the cuboid and returns a new axis-aligned cuboid resulting from this rotation. Not sure it it makes any sense to use this for other rotations than 90 degree intervals.
 /// </summary>
 public Cuboidi RotatedCopy(IVec3 vec, Vec3d origin)
 {
     return(RotatedCopy(vec.XAsInt, vec.YAsInt, vec.ZAsInt, origin));
 }
Esempio n. 2
0
 /// <summary>
 /// Returns a new cuboid offseted by given position
 /// </summary>
 public Cuboidi OffsetCopy(IVec3 vec)
 {
     return(OffsetCopy(vec.XAsInt, vec.YAsInt, vec.ZAsInt));
 }
Esempio n. 3
0
 /// <summary>
 /// Grows the cuboid so that it includes the given block
 /// </summary>
 public Cuboidi GrowToInclude(IVec3 vec)
 {
     GrowToInclude(vec.XAsInt, vec.YAsInt, vec.ZAsInt);
     return(this);
 }
Esempio n. 4
0
 /// <summary>
 /// Returns the shortest distance between given point and any point inside the cuboid
 /// </summary>
 public double ShortestDistanceFrom(IVec3 vec)
 {
     return(ShortestDistanceFrom(vec.XAsInt, vec.YAsInt, vec.ZAsInt));
 }
Esempio n. 5
0
 /// <summary>
 /// Substractes the given offset to the cuboid
 /// </summary>
 public Cuboidi Sub(IVec3 vec)
 {
     Sub(vec.XAsInt, vec.YAsInt, vec.ZAsInt);
     return(this);
 }
Esempio n. 6
0
 /// <summary>
 /// Returns if the given point is inside the cuboid
 /// </summary>
 public bool ContainsOrTouches(IVec3 vec)
 {
     return(ContainsOrTouches(vec.XAsInt, vec.YAsInt, vec.ZAsInt));
 }
Esempio n. 7
0
 /// <summary>
 /// Sets the minimum and maximum values of the cuboid
 /// </summary>
 public Cuboidi Set(IVec3 min, IVec3 max)
 {
     Set(min.XAsInt, min.YAsInt, min.ZAsInt, max.XAsInt, max.YAsInt, max.ZAsInt);
     return(this);
 }
Esempio n. 8
0
 /// <summary>
 /// Adds the given offset to the cuboid
 /// </summary>
 public Cuboidi Translate(IVec3 vec)
 {
     Translate(vec.XAsInt, vec.YAsInt, vec.ZAsInt);
     return(this);
 }
Esempio n. 9
0
        public static IVec3 Normalized(IVec3 vec)
        {
            float dist = GetLength(vec);

            return(vec.GetNewInstance(vec.X / dist, vec.Y / dist, vec.Z / dist));
        }
Esempio n. 10
0
 public static IVec3 Dot(IVec3 left, IVec3 right)
 {
     return(left.GetNewInstance(left.X * right.X, left.Y * right.Y, left.Z * right.Z));
 }
Esempio n. 11
0
 public static IVec3 Scale(IVec3 vec, IVec3 scalar)
 {
     return(vec.GetNewInstance(vec.X * scalar.X, vec.Y * scalar.Y, vec.Z * scalar.Z));
 }
Esempio n. 12
0
 public static IVec3 Scale(IVec3 vec, float scalar)
 {
     return(vec.GetNewInstance(vec.X * scalar, vec.Y * scalar, vec.Z * scalar));
 }
Esempio n. 13
0
 public static float GetLength(IVec3 vec)
 {
     return((float)Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y + vec.Z * vec.Z));
 }
Esempio n. 14
0
        public static float GetDistance(IVec3 vec1, IVec3 vec2)
        {
            IVec3 dir = Subtract(vec1, vec2);

            return(GetLength(dir));
        }
Esempio n. 15
0
        public static IVec3 Lerp(IVec3 from, IVec3 to, float t)
        {
            IVec3 dir = VectorMath.Subtract(to, from);

            return(VectorMath.Add(from, VectorMath.Scale(dir, t)));
        }