|
@@ -0,0 +1,62 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace bbiwarg.Utility
|
|
|
+{
|
|
|
+ class Vector3D
|
|
|
+ {
|
|
|
+ public float X { get; private set; }
|
|
|
+ public float Y { get; private set; }
|
|
|
+ public float Z { get; private set; }
|
|
|
+ public int IntX { get { return (int)X; } }
|
|
|
+ public int IntY { get { return (int)Y; } }
|
|
|
+ public int IntZ { get { return (int)Z; } }
|
|
|
+ public float Length { get { return (float)Math.Sqrt(X * X + Y * Y + Z * Z); } }
|
|
|
+
|
|
|
+ public Vector3D(float x, float y, float z)
|
|
|
+ {
|
|
|
+ X = x;
|
|
|
+ Y = y;
|
|
|
+ Z = z;
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getDistanceTo(Vector3D point)
|
|
|
+ {
|
|
|
+ return (this - point).Length;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Vector3D operator *(float scalar, Vector3D v)
|
|
|
+ {
|
|
|
+ return new Vector3D(scalar * v.X, scalar * v.Y, scalar * v.Z);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Vector3D operator *(Vector3D v, float scalar)
|
|
|
+ {
|
|
|
+ return new Vector3D(scalar * v.X, scalar * v.Y, scalar * v.Z);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Vector3D operator /(Vector3D v, float scalar)
|
|
|
+ {
|
|
|
+ return new Vector3D(v.X / scalar, v.Y / scalar, v.Z / scalar);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Vector3D operator /(Vector3D v1, Vector3D v2)
|
|
|
+ {
|
|
|
+ return new Vector3D(v1.X / v2.X, v1.Y / v2.Y, v1.Z / v2.Z);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Vector3D operator +(Vector3D v1, Vector3D v2)
|
|
|
+ {
|
|
|
+ return new Vector3D(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Vector3D operator -(Vector3D v1, Vector3D v2)
|
|
|
+ {
|
|
|
+ return new Vector3D(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|