コード例 #1
0
        public Vector3P Transform(Vector3P xyz)
        {
            var vQ    = new Quaternion(xyz.X, xyz.Y, xyz.Z, 0);
            var vQnew = this * vQ * Inverse;

            return(new Vector3P(vQnew.x, vQnew.y, vQnew.z));
        }
コード例 #2
0
ファイル: Vector.cs プロジェクト: mastertnt/bis-file-formats
        public static Vector3P CrossProduct(Vector3P a, Vector3P b)
        {
            var x = a.Y * b.Z - a.Z * b.Y;
            var y = a.Z * b.X - a.X * b.Z;
            var z = a.X * b.Y - a.Y * b.X;

            return(new Vector3P(x, y, z));
        }
コード例 #3
0
ファイル: Matrix.cs プロジェクト: mastertnt/bis-file-formats
 private Matrix3P(Vector3P aside, Vector3P up, Vector3P dir)
 {
     columns = new Vector3P[3]
     {
         aside,
         up,
         dir
     };
 }
コード例 #4
0
ファイル: Matrix.cs プロジェクト: mastertnt/bis-file-formats
 public void SetTilda(Vector3P a)
 {
     Aside.Y = -a.Z;
     Aside.Z = a.Y;
     Up.X    = a.Z;
     Up.Z    = -a.X;
     Dir.X   = -a.Y;
     Dir.Y   = a.X;
 }
コード例 #5
0
        public static TransformP Read(BinaryReaderEx input)
        {
            var quaternion = QuaternionP.ReadCompressed(input);
            var x          = new ShortFloat(input.ReadUInt16());
            var y          = new ShortFloat(input.ReadUInt16());
            var z          = new ShortFloat(input.ReadUInt16());
            var vector     = new Vector3P((float)x.DoubleValue, (float)y.DoubleValue, (float)z.DoubleValue);

            return(new TransformP(quaternion, vector));
        }
コード例 #6
0
ファイル: Vector.cs プロジェクト: mastertnt/bis-file-formats
        public override bool Equals(object obj)
        {
            Vector3P p = obj as Vector3P;

            if (p == null)
            {
                return(false);
            }

            return(base.Equals(obj) && Equals(p));
        }
コード例 #7
0
ファイル: Vector.cs プロジェクト: mastertnt/bis-file-formats
        public float Distance(Vector3P v)
        {
            var d = this - v;

            return((float)System.Math.Sqrt(d.X * d.X + d.Y * d.Y + d.Z * d.Z));
        }
コード例 #8
0
ファイル: Vector.cs プロジェクト: mastertnt/bis-file-formats
        public bool Equals(Vector3P other)
        {
            Func <float, float, bool> nearlyEqual = (f1, f2) => System.Math.Abs(f1 - f2) < 0.05;

            return(nearlyEqual(X, other.X) && nearlyEqual(Y, other.Y) && nearlyEqual(Z, other.Z));
        }
コード例 #9
0
 public TransformP(QuaternionP quaternion, Vector3P vector)
 {
     this.quaternion = quaternion;
     this.vector     = vector;
 }
コード例 #10
0
 public Vector3P Transform(Vector3P xyz)
 {
     return(new Vector3P(System.Numerics.Vector3.Transform(xyz.Vector3, quaternion)));
 }
コード例 #11
0
ファイル: Matrix.cs プロジェクト: mastertnt/bis-file-formats
 private Matrix4P(Matrix3P orientation, Vector3P position)
 {
     Orientation = orientation;
     Position    = position;
 }
コード例 #12
0
 public static Vector3P CrossProduct(Vector3P a, Vector3P b)
 {
     return(new Vector3P(Vector3.Cross(a.xyz, b.xyz)));
 }
コード例 #13
0
 public float Distance(Vector3P v)
 {
     return(Vector3.Distance(xyz, v.xyz));
 }