Ejemplo n.º 1
0
        /// <summary>
        /// Stores the values of the given Transform in a Transformd struct. Note: Very inefficient.
        /// </summary>
        public static Transformd StoreTransform(UnityEngine.Transform transform)
        {
            Quatd    rotation = transform.localRotation;
            Vector3d position = transform.localPosition;

            return(new Transformd(rotation, position));
        }
Ejemplo n.º 2
0
        public static Vector4d AxisAngle(Quatd q)
        {
            double angle = 2 * Mathd.Acos(q.w);
            double den   = Mathd.Sqrt(1 - q.w * q.w);

            if (den == 0)
            {
                return(new Vector4d(0, 0, -1, angle));
            }
            return(new Vector4d(q.x / den, q.y / den, q.z / den, angle));
        }
Ejemplo n.º 3
0
        public Transformd InterpolateWith(Transformd Transformd, double c)
        {
            /* not sure if very "efficient" but good enough? */

            Vector3d sourceScale    = basis.Scale;
            Quatd    sourceRotation = basis.RotationQuatd();
            Vector3d sourceLocation = origin;

            Vector3d destinationScale    = Transformd.basis.Scale;
            Quatd    destinationRotation = Transformd.basis.RotationQuatd();
            Vector3d destinationLocation = Transformd.origin;

            var interpolated = new Transformd();

            interpolated.basis.SetQuatScale(sourceRotation.Slerp(destinationRotation, c).Normalized(), sourceScale.LinearInterpolate(destinationScale, c));
            interpolated.origin = sourceLocation.LinearInterpolate(destinationLocation, c);

            return(interpolated);
        }
Ejemplo n.º 4
0
 public Transformd(Quatd quat, Vector3d origin)
 {
     basis       = new Basisd(quat);
     this.origin = origin;
 }