Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="y"></param>
        /// <param name="yz"></param>
        /// <returns></returns>
        public static OrthoBasis3d CreateFromYZ(Vector3d y, Vector3d yz)
        {
            OrthoBasis3d result = default;

            result.SetYZ(y, yz);
            return(result);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="up"></param>
        /// <returns></returns>
        public static Quaterniond CreateLookAt(Vector3d direction, Vector3d up)
        {
            // impl ref
            // http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/

            return(new Quaterniond(OrthoBasis3d.CreateLookAt(direction, up)));
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="x"></param>
        /// <param name="xz"></param>
        /// <returns></returns>
        public static OrthoBasis3d CreateFromXZ(Vector3d x, Vector3d xz)
        {
            OrthoBasis3d result = default;

            result.SetXY(x, xz);
            return(result);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="z"></param>
        /// <param name="xz"></param>
        /// <returns></returns>
        public static OrthoBasis3d CreateFromZX(Vector3d z, Vector3d xz)
        {
            OrthoBasis3d result = default;

            result.SetZX(z, xz);
            return(result);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="y"></param>
        /// <param name="xy"></param>
        /// <returns></returns>
        public static OrthoBasis3d CreateFromYX(Vector3d y, Vector3d xy)
        {
            OrthoBasis3d result = default;

            result.SetYX(y, xy);
            return(result);
        }
Пример #6
0
        /// <summary>
        /// Applies the inverse of this rotation to the given rotation in place.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public OrthoBasis3d ApplyInverse(ref OrthoBasis3d other)
        {
            var x = ApplyInverse(other._x);
            var y = ApplyInverse(other._y);

            return(new OrthoBasis3d
            {
                _x = x,
                _y = y,
                _z = Vector3d.Cross(x, y)
            });
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rotation"></param>
        public void Set(ref OrthoBasis3d rotation)
        {
            // impl ref
            // http://www.cs.ucr.edu/~vbz/resources/quatut.pdf

            (var x, var y, var z) = rotation;
            double trace = x.X + y.Y + z.Z;

            if (trace > 0.0)
            {
                double s = Math.Sqrt(trace + 1.0);
                W = 0.5 * s;

                s = 0.5 / s;
                X = (y.Z - z.Y) * s;
                Y = (z.X - x.Z) * s;
                Z = (x.Y - y.X) * s;
            }
            else if (Math.Abs(x.X) > Math.Abs(y.Y) && Math.Abs(x.X) > Math.Abs(z.Z))
            {
                double s = Math.Sqrt(1.0 + x.X - y.Y - z.Z);
                X = 0.5 * s;

                s = 0.5 / s;
                Y = (x.Y + y.X) * s;
                Z = (z.X + x.Z) * s;
                W = (y.Z - z.Y) * s;
            }
            else if (Math.Abs(y.Y) > Math.Abs(z.Z))
            {
                double s = Math.Sqrt(1.0 - x.X + y.Y - z.Z);
                Y = 0.5 * s;

                s = 0.5 / s;
                X = (x.Y + y.X) * s;
                Z = (y.Z + z.Y) * s;
                W = (z.X - x.Z) * s;
            }
            else
            {
                double s = Math.Sqrt(1.0 - x.X - y.Y + z.Z);
                Z = 0.5 * s;

                s = 0.5 / s;
                X = (z.X + x.Z) * s;
                Y = (y.Z + z.Y) * s;
                W = (x.Y - y.X) * s;
            }
        }
Пример #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public Quaterniond(OrthoBasis3d rotation)
     : this()
 {
     Set(ref rotation);
 }
Пример #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eye"></param>
 /// <param name="target"></param>
 /// <param name="up"></param>
 /// <returns></returns>
 public static Orient3d CreateLookAt(Vector3d eye, Vector3d target, Vector3d up)
 {
     return(new Orient3d(OrthoBasis3d.CreateLookAt(target - eye, up), eye));
 }
Пример #10
0
 /// <summary>
 /// Creates a relative rotation from r0 to r1.
 /// </summary>
 /// <param name="from"></param>
 /// <param name="to"></param>
 public static OrthoBasis3d CreateFromTo(OrthoBasis3d from, OrthoBasis3d to)
 {
     return(CreateFromTo(ref from, ref to));
 }
Пример #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 /// <param name="translation"></param>
 public void Deconstruct(out OrthoBasis3d rotation, out Vector3d translation)
 {
     rotation    = Rotation;
     translation = Translation;
 }
Пример #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <returns></returns>
 public static Orient3d CreateFromPoints(Vector3d p0, Vector3d p1, Vector3d p2)
 {
     return(new Orient3d(OrthoBasis3d.CreateFromXY(p1 - p0, p2 - p0), p0));
 }
Пример #13
0
 /// <summary>
 /// Applies this rotation to the given rotation in place.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public OrthoBasis3d Apply(OrthoBasis3d other)
 {
     return(Apply(ref other));
 }
Пример #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 /// <param name="translation"></param>
 public Orient3d(OrthoBasis3d rotation, Vector3d translation)
 {
     Rotation    = rotation;
     Translation = translation;
 }
Пример #15
0
 /// <summary>
 /// Applies the given rotation to the axis of this rotation.
 /// </summary>
 /// <param name="rotation"></param>
 public void RotateAxis(ref OrthoBasis3d rotation)
 {
     _axis = rotation.Apply(_axis);
 }
Пример #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="scale"></param>
 /// <param name="rotation"></param>
 /// <param name="translation"></param>
 public Transform3d(Vector3d scale, OrthoBasis3d rotation, Vector3d translation)
 {
     Scale       = scale;
     Rotation    = rotation;
     Translation = translation;
 }
Пример #17
0
        /// <summary>
        /// Creates a relative rotation from r0 to r1.
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        public static OrthoBasis3d CreateFromTo(ref OrthoBasis3d from, ref OrthoBasis3d to)
        {
            var inv = from.Inverse;

            return(to.Apply(ref inv));
        }
Пример #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public bool Set(ref OrthoBasis3d rotation)
 {
     return(Set(new Quaterniond(rotation)));
 }
Пример #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public AxisAngle3d(OrthoBasis3d rotation)
     : this()
 {
     Set(ref rotation);
 }
Пример #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <param name="epsilon"></param>
 /// <returns></returns>
 public bool ApproxEquals(ref OrthoBasis3d other, double epsilon = D.ZeroTolerance)
 {
     return
         (_x.ApproxEquals(other._x, epsilon) &&
          _y.ApproxEquals(other._y, epsilon));
 }
Пример #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <param name="epsilon"></param>
 /// <returns></returns>
 public bool ApproxEquals(OrthoBasis3d other, double epsilon = D.ZeroTolerance)
 {
     return(ApproxEquals(ref other, epsilon));
 }
Пример #22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public void Set(OrthoBasis3d rotation)
 {
     Set(ref rotation);
 }
Пример #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="scale"></param>
 /// <param name="orientation"></param>
 public Transform3d(Vector3d scale, Orient3d orientation)
 {
     Scale       = scale;
     Rotation    = orientation.Rotation;
     Translation = orientation.Translation;
 }
Пример #24
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 /// <returns></returns>
 public bool Set(OrthoBasis3d rotation)
 {
     return(Set(ref rotation));
 }
Пример #25
0
 /// <summary>
 /// Applies the inverse of this rotation to the given rotation in place.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public OrthoBasis3d ApplyInverse(OrthoBasis3d other)
 {
     return(ApplyInverse(ref other));
 }