// https://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another public static __rot3t__ HalfWayVec(__v3t__ from, __v3t__ into) { if (from.Dot(into).ApproximateEquals(-1)) { return(new __rot3t__(0, from.AxisAlignedNormal())); } else { __v3t__ half = Vec.Normalized(from + into); __quatt__ q = new __quatt__(Vec.Dot(from, half), Vec.Cross(from, half)); return(new __rot3t__(q.Normalized)); } }
public static __rot3t__ HalfWayQuat(__v3t__ from, __v3t__ into) { var d = Vec.Dot(from, into); if (d.ApproximateEquals(-1)) { return(new __rot3t__(0, from.AxisAlignedNormal())); } else { __quatt__ q = new __quatt__(d + 1, Vec.Cross(from, into)); return(new __rot3t__(q.Normalized)); } }
public static __rot3t__ Original(__v3t__ from, __v3t__ into) { var angle = from.AngleBetween(into); //# var rotIntoEps = isDouble ? "1e-15" : "1e-6f"; if (angle < __rotIntoEps__) { return(__rot3t__.Identity); } else if (__pi__ - angle < __rotIntoEps__) { return(new __rot3t__(0, from.AxisAlignedNormal())); } else { __v3t__ axis = Vec.Cross(from, into).Normalized; return(__rot3t__.Rotation(axis, angle)); } }