Exemple #1
0
        /// <summary>
        /// Projects this vector onto other vector.
        /// </summary>
        /// <param name="other">The vector being projected onto</param>
        /// <returns></returns>
        [Pure] public IntVector2 LossyProjectOnto(IntVector2 other)
        {
            var numerator   = other.Dot(this);
            var denominator = other.SquaredNorm2();

            return(new IntVector2(
                       (cInt)((other.X * numerator) / denominator),
                       (cInt)((other.Y * numerator) / denominator)));
        }
Exemple #2
0
 /// <summary>
 /// result * other ~= Proj(this onto other)
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 [Pure] public double ProjectOntoComponentD(IntVector2 other)
 {
     return(other.Dot(this) / (double)other.SquaredNorm2());
 }