示例#1
0
        /// <summary>
        /// Projects this vector onto other vector.
        /// </summary>
        /// <param name="other">The vector being projected onto</param>
        /// <returns></returns>
        public DoubleVector2 ProjectOnto(DoubleVector2 other)
        {
            var numerator   = other.Dot(this);
            var denominator = other.SquaredNorm2D();

            return(new DoubleVector2(
                       (other.X * numerator) / denominator,
                       (other.Y * numerator) / denominator));
        }
示例#2
0
 /// <summary>
 /// result * other ~= Proj(this onto other)
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public double ProjectOntoComponentD(DoubleVector2 other)
 {
     return(other.Dot(this) / other.SquaredNorm2D());
 }