/// <summary> /// vytvori oblouk zadany pocatecnim bodem, vektorem ve kterm je koncovy bod a zdvihem v poloine usecky /// </summary> /// <param name="pt1">pocatecni bod oblouku</param> /// <param name="v">vektor udavajici koncovy bod oblouky</param> /// <param name="elevation">zdvih oblouku v polovine usecky [pt1,v]</param> /// <returns></returns> public static Arc2D Arc2DElevation(Point pt1, Vector v, double elevation) { Point pt2, pt3 = pt1.Plus(v); pt2 = Funcs2D.PointOnLineLen(Funcs2D.PointOnLine(pt1, v, 0.5), Funcs2D.VectorNormal(v), elevation); return(new Arc2D(pt1, pt2, pt3)); }
public Point CrossPoint(int inx, double[,] p) { int i = -1; for (i = 0; i < myCross.Count; i++) { if (myCross[i].Inx == inx) { break; } } return(Funcs2D.PointOnLine(new Point(p[myBegin, 0], p[myBegin, 1]), new Point(p[myEnd, 0], p[myEnd, 1]), myCross[i].Rel)); }
public bool NextPoint(ref DataPTR ptr, double[,] p) { //Debug.Assert(ptr.inxPt == myBegin); if (ptr.inxPt == -1) // pocatecni bod { //DODO POZOR muze byt prusecik na zacatku, ptr.inxCrLn = -1; ptr.inxPt = 0; ptr.pPt = BeginPoint(p); ptr.kRel = 0; return(true); } if (IsCrossing && ptr.inxPt < myCross.Count) { ptr.pPt = Funcs2D.PointOnLine(new Point(p[myBegin, 0], p[myBegin, 1]), new Point(p[myEnd, 0], p[myEnd, 1]), myCross[ptr.inxPt].Rel); ptr.kRel = myCross[ptr.inxPt].Rel; ptr.inxCrLn = myCross[ptr.inxPt].Inx; ptr.inxPt++; return(true); } ptr.inxCrLn = -1; ptr.inxPt = -1; return(false); }
/// <summary> /// oblouk tvoreny dvema po sobe jdoucimi useckami a polomerem /// takzvane zaobleni rohu /// pokud je polomer zaporny vytvori se tzv. vykousnuti se stredem ve spolecnem bode /// objekt se nastavi na empty pokud jsou usecky rovnobezne nebo jedna z nich ma nulovou delku /// </summary> /// <param name="pt1">pocatecni bod prvni ridici usecky</param> /// <param name="pt2">spolecny bod ridicich usecek</param> /// <param name="pt3">konecny bod druhe ridici usecky</param> /// <param name="radius">polomer zaobleni, zaporny polomer provede vykousnuti</param> /// <param name="testPt">pokud se pocatecni nebo koncovy bod vypocita mimo usecku, objekt se nastavi na Empty</param> public Arc2D(Point pt1, Point pt2, Point pt3, double radius, bool testPt = false) { // zjistim smer offsetu double a = Vector.AngleBetween(pt2.Minus(pt1), pt3.Minus(pt2)); if (a > 0) { a = -Math.Abs(radius); Clockwise = false; } else { a = Math.Abs(radius); Clockwise = true; } // vypocitam prusecik offsetovanych primek Point[] p1 = Funcs2D.LineOffset(pt1, pt2, a); Point[] p2 = Funcs2D.LineOffset(pt2, pt3, a); if (p1 == null || p2 == null || !TwoLine2D.CrossRel(p1[0], p1[1], p2[0], p2[1], out Point rr)) { // tri body na jedne primce Begin = pt1; End = pt3; Radius = 0; return; } if (radius > 0) { if (testPt) { if (!TwoLine2D.TestRelOnLine(TwoLine2D.CrossStatus.And, rr.X) || !TwoLine2D.TestRelOnLine(TwoLine2D.CrossStatus.And, rr.Y)) { // body jsou mimo usecky Begin = pt1; End = pt3; Radius = 0; return; } } // koeficienty prenesu do puvodnich usecek a spocitam body Begin = Funcs2D.PointOnLine(pt1, pt2, rr.X); End = Funcs2D.PointOnLine(pt2, pt3, rr.Y); Radius = radius; } else { Radius = -radius; if (testPt) { if (Funcs2D.Distance(pt1, pt2) < Radius || Funcs2D.Distance(pt2, pt3) < Radius) { // body jsou mimo usecky Begin = pt1; End = pt3; Radius = 0; return; } } // bod na prvni primce ve vzdalenosti abs(radius) od spolecneho bodu Begin = Funcs2D.PointOnLineLen(pt2, pt1, Radius); // bod na druhe primce End = Funcs2D.PointOnLineLen(pt2, pt3, Radius); Clockwise = !Clockwise; } }