Esempio n. 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));
        }
Esempio n. 2
0
        private void InsertInternal(ref IntLineSegment2 s, double insertionThetaLower, double insertionThetaUpper, bool supportOverlappingLines)
        {
            if (insertionThetaLower == insertionThetaUpper)
            {
                return;
            }

            //         Console.WriteLine($"InsertInternal: {s}, {thetaLower} {thetaUpper}");

            // cull if wall faces away from origin
            var sperp = new DoubleVector2(s.Y2 - s.Y1, -(s.X2 - s.X1));
            var os1   = _origin.To(s.First.ToDoubleVector2());

            if (sperp.Dot(os1) < 0)
            {
                //return;
            }
            var rangeId = rangeIdCounter++;

            InsertInternalInternal(s, rangeId, insertionThetaLower, insertionThetaUpper, supportOverlappingLines, false);
        }
Esempio n. 3
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());
 }