コード例 #1
0
        /// <summary>
        /// crosses the triangle with a line. It returns true if the cross point is inside the triangle. In this case <b>Lam</b> and <b>Point</b> will be calculated.
        /// You get the cross point <b>Pt</b> by L.Value(Lam).
        /// </summary>
        /// <param name="L">is the line</param>
        /// <param name="Pt">is the cross point</param>
        /// <param name="Lam">is the parameter. You get the cross point <b>Pt</b> by L.Value(Lam).</param>
        /// <returns></returns>
        public bool Cross(LineType L, ref xyzf Pt, ref double Lam)
        {
            Plane P1 = new Plane(A, B, C);
            xyz   P  = new xyz(0, 0, 0);

            Lam = -1;
            if (P1.Cross(L, out Lam, out P))
            {
                xyz PP = L.Value(Lam);
                Pt = new Drawing3d.xyzf((float)P.x, (float)P.y, (float)P.z);
                if (Inside(P.toXYZF()))
                {
                    Pt = P.toXYZF();
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: Curve.cs プロジェクト: unitycoder/Drawing3D
        /// <summary>
        /// Gets the distance to a line.
        /// </summary>
        /// <param name="L">A line</param>
        /// <param name="MaxDist">maximal distance</param>
        /// <param name="param">Parameter relative to this curve</param>
        /// <param name="lam">Prameter relative to L</param>
        /// <returns>The distance</returns>
        public double Distance(LineType L, double MaxDist, out double param, out double lam)
        {
            double  result = Utils.big;
            xyArray a      = new xyArray(Resolution + 1);

            this.ToArray(a, 0);
            double di = a.Distance(L, MaxDist, out param, out lam);

            xyz    P = L.Value(lam);
            xyz    Q = Value(param).toXYZ();
            double T = P.dist(Q);

            if (!Utils.Less(MaxDist, di))
            {
                param  = this.fromParam + param * toParam / Resolution;
                result = di;
            }
            return(result);
        }