コード例 #1
0
ファイル: Arc.cs プロジェクト: yasenRK/ThePipe
        public Arc(Vec startPt, Vec endPt, Vec ptOnArc)
        {
            Vec midPt1 = Vec.Multiply(Vec.Sum(endPt, ptOnArc), 0.5);
            Vec midPt2 = Vec.Multiply(Vec.Sum(startPt, ptOnArc), 0.5);

            Vec seg1 = Vec.Difference(ptOnArc, startPt);
            Vec seg2 = Vec.Difference(endPt, ptOnArc);

            Vec planeZ = Vec.Cross(seg1, seg2);

            Vec rad1 = Vec.Cross(planeZ, seg1);
            Vec rad2 = Vec.Cross(planeZ, seg2);

            Vec center = Vec.IntersectLines(midPt1, rad1, midPt2, rad2);
            Vec planeX = Vec.Difference(startPt, center);
            Vec planeY = Vec.Cross(planeZ, planeX);

            _plane      = new Plane(center, planeX, planeY, planeZ);
            _radius     = Vec.Difference(center, startPt).Length;
            _startAngle = 0;
            _endAngle   = 2 * Vec.AngleBetween(rad1, rad2);
        }