Пример #1
0
 // Linear Interpolation between two points
 // Implementation adapted from: http://www.blueraja.com/blog/404/how-to-use-unity-3ds-linear-interpolation-vector3-lerp-correctly#comment-23334
 static public Mathd.Vector3 Lerp(Mathd.Vector3 start, Mathd.Vector3 end, float t)
 {
     // Ensure requested distance along interpolation is between 0 and 1
     t = UnityEngine.Mathf.Clamp01(t);
     // Method guarantees the return will equal the end position when t = 1
     return(new Mathd.Vector3((1 - t) * start) + (t * end));
 }
Пример #2
0
        public Quaternion(UnityEngine.Quaternion quat)
        {
            vector_ = new Mathd.Vector3();

            scalar_   = quat.w;
            vector_.x = quat.x;
            vector_.y = quat.y;
            vector_.z = quat.z;
        }
Пример #3
0
        // CONSRUCTORS //

        public Quaternion(float w, float x, float y, float z)
        {
            vector_ = new Mathd.Vector3();

            scalar_   = w;
            vector_.x = x;
            vector_.y = y;
            vector_.z = z;
        }
Пример #4
0
 // This is the one to use for building a transform
 // Based on example from: http://wscg.zcu.cz/wscg2012/short/A29-full.pdf
 public DualQuaternion(Mathd.Vector3 position, Mathd.Quaternion rotation)
 {
     real = rotation.normalised;
     dual = 0.5f * (new Mathd.Quaternion(0, position) * real);
 }
Пример #5
0
 public Quaternion(float w, Mathd.Vector3 xyz)
 {
     scalar_ = w;
     vector_ = xyz;
 }
Пример #6
0
 // Distance between two points
 static public float Distance(Mathd.Vector3 start, Mathd.Vector3 end)
 {
     return(new Mathd.Vector3(end - start).magnitude);
 }
Пример #7
0
 // Cross Product (Left handed)
 // Normal to the plane defined by the two vectors
 // Has length = to the area of the parallelogram formed by the two vectors
 static public Mathd.Vector3 CrossProduct(Mathd.Vector3 lhs, Mathd.Vector3 rhs)
 {
     return(new Mathd.Vector3((lhs.y * rhs.z) - (lhs.z * rhs.y),
                              (lhs.z * rhs.x) - (lhs.x * rhs.z),
                              (lhs.x * rhs.y) - (lhs.y * rhs.x)));
 }
Пример #8
0
 // Dot Product
 // The angle between two vectors
 // If the same vector is used both sides = magnitude of the vector, squared
 static public float DotProduct(Mathd.Vector3 lhs, Mathd.Vector3 rhs)
 {
     return((lhs.x * rhs.x) + (lhs.y * rhs.y) + (lhs.z * rhs.z));
 }
Пример #9
0
 public Vector3(Mathd.Vector3 vec3)
 {
     x_ = vec3.x;
     y_ = vec3.y;
     z_ = vec3.z;
 }