예제 #1
0
 /// <summary>
 /// Applies the inverse of this rotation to the given rotation.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public void ApplyInverse(ref OrthoBasis3d other, ref OrthoBasis3d result)
 {
     result.SetXY(
         ApplyInverse(other._x),
         ApplyInverse(other._y)
         );
 }
예제 #2
0
 /// <summary>
 /// Applies the inverse of this rotation to the given rotation.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public void ApplyInverse(ref OrthoBasis3d other)
 {
     other.SetXY(
         ApplyInverse(other._x),
         ApplyInverse(other._y)
         );
 }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eye"></param>
        /// <param name="target"></param>
        /// <param name="up"></param>
        /// <returns></returns>
        public static Orient3d CreateLookAt(Vec3d eye, Vec3d target, Vec3d up)
        {
            var rot = new OrthoBasis3d(target - eye, up);

            rot.SwapZX();

            var orient = new Orient3d(rot, eye);

            orient.Invert();

            return(orient);
        }
예제 #4
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;
            }
        }
예제 #5
0
 /// <summary>
 /// Applies the inverse of this rotation to the given rotation in place.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public void ApplyInverse(ref OrthoBasis3d other)
 {
     ApplyInverse(ref other, ref other);
 }
예제 #6
0
 /// <summary>
 /// Applies the inverse of this rotation to the given rotation.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public OrthoBasis3d ApplyInverse(OrthoBasis3d other)
 {
     ApplyInverse(ref other, ref other);
     return(other);
 }
예제 #7
0
 /// <summary>
 /// Applies this rotation to the given rotation in place.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public void Apply(ref OrthoBasis3d other)
 {
     Apply(ref other, ref other);
 }
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public bool Set(ref OrthoBasis3d rotation)
 {
     return(Set(new Quaterniond(rotation)));
 }
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="scale"></param>
 /// <param name="orientation"></param>
 public Transform3d(Vec3d scale, Orient3d orientation)
 {
     Scale       = scale;
     Rotation    = orientation.Rotation;
     Translation = orientation.Translation;
 }
예제 #10
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)
 {
     return(to.Apply(from.Inverse));
 }
예제 #11
0
 /// <summary>
 /// Assumes the given rotation is valid.
 /// </summary>
 /// <param name="rotation"></param>
 public void Set(OrthoBasis3d rotation)
 {
     Set(ref rotation);
 }
예제 #12
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);
 }
예제 #13
0
 /// <summary>
 /// Applies the given rotation to the axis of this rotation.
 /// </summary>
 /// <param name="rotation"></param>
 public void RotateAxis(OrthoBasis3d rotation)
 {
     RotateAxis(ref rotation);
 }
예제 #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public void Set(ref OrthoBasis3d rotation)
 {
     Set(new Quaterniond(rotation));
 }
예제 #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public AxisAngle3d(OrthoBasis3d rotation)
     : this()
 {
     Set(ref rotation);
 }
예제 #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <param name="tolerance"></param>
 /// <returns></returns>
 public bool ApproxEquals(ref OrthoBasis3d other, double tolerance = SlurMath.ZeroTolerance)
 {
     return
         (_x.ApproxEquals(other._x, tolerance) &&
          _y.ApproxEquals(other._y, tolerance));
 }
예제 #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 /// <param name="translation"></param>
 public Orient3d(OrthoBasis3d rotation, Vec3d translation)
 {
     Rotation    = rotation;
     Translation = translation;
 }
예제 #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public Quaterniond(OrthoBasis3d rotation)
     : this()
 {
     Set(ref rotation);
 }
예제 #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="origin"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public Orient3d(Vec3d origin, Vec3d x, Vec3d y)
 {
     Rotation    = new OrthoBasis3d(x, y);
     Translation = origin;
 }
예제 #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="scale"></param>
 /// <param name="rotation"></param>
 /// <param name="translation"></param>
 public Transform3d(Vec3d scale, OrthoBasis3d rotation, Vec3d translation)
 {
     Scale       = scale;
     Rotation    = rotation;
     Translation = translation;
 }
예제 #21
0
 /// <summary>
 /// Applies this rotation to the given rotation.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public OrthoBasis3d Apply(OrthoBasis3d other)
 {
     Apply(ref other, ref other);
     return(other);
 }
예제 #22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 public void Deconstruct(out Vec3d scale, out OrthoBasis3d rotation, out Vec3d translation)
 {
     scale       = Scale;
     rotation    = Rotation;
     translation = Translation;
 }
예제 #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="origin"></param>
 /// <param name="xAxis"></param>
 /// <param name="xyVector"></param>
 public Orient3d(Vec3d origin, Vec3d xAxis, Vec3d xyVector)
 {
     Rotation    = new OrthoBasis3d(xAxis, xyVector);
     Translation = origin;
 }