private double calcAngle(Edge end, Edge start) { Vector p1 = end.Line.getDirectionVector(); Vector p2 = start.Line.getDirectionVector(); if (p1 == p2) { return(Math.PI); } Line la = new Line(end.Line.Start, start.Line.End); double b = end.Line.Length(); double c = start.Line.Length(); double a = la.Length(); double cosA = (Math.Pow(b, 2) + Math.Pow(c, 2) - Math.Pow(a, 2)) / (2 * b * c); double cosAmod = Math.Max(Math.Min(cosA, 0.9999999999999), -0.9999999999999); double A = Math.Acos(cosAmod); Point ccp = la.getCenterPoint(); Point ecp = end.Line.Offset(10).getCenterPoint(); Line aa = new Line(ccp, ecp); Line bb = end.Line.extendDouble(10 * start.Line.Length()); if (Line.hasIntersection(aa, bb)) { A = 2 * Math.PI - A; } return(A); }
public A_Raud(G.Line main, int nr, int d, string teras) : base(main, nr, d, teras) { _A = shorter(main.Length()); _IP = main.getCenterPoint(); _Length = _A; }
private bool insanityCheck() { for (int i = corners.Count - 1; i >= 0; i--) { Corner c = corners[i]; if (Math.Abs(c.Angle - Math.PI) < _Variables.FLAT_CORNER_TOLERANCE) { Edge start = c.StartEdge; Edge end = c.EndEdge; Line new_line = new Line(end.Line.Start, start.Line.End); Point center = new_line.getCenterPoint(); Vector offset = new_line.getOffsetVector(); Point p = center.move(_Variables.MOVE_DISTANCE, offset); bool inSide = isPointinRegion(p); if (inSide) { Edge e = new Edge(new_line); edges.Add(e); edges.Remove(start); edges.Remove(end); return(false); } else { throw new RegionLineNotInRegionException(); } } } return(true); }
public D_Raud(G.Line side1, int z_dist, int nr, int d, string teras) : base(side1, nr, d, teras) { _A = shorter(side1.Length()); _B = shorter(z_dist); // parand magic _B2 = _B; // parand magic _C = shorter(side1.Length()); _IP = side1.getCenterPoint(); _Length = _A + _B + _C; }
private void setEdges(List <Line> contours) { foreach (Line line in contours) { Point center = line.getCenterPoint(); Vector offset = line.getOffsetVector(); Vector dir = line.getDirectionVector(); Point p = center.move(_Variables.MOVE_DISTANCE, offset); p = p.move(_Variables.MOVE_DISTANCE, dir); bool inSide = Region_Static.isPointinRegion(p, offset, contours); if (inSide) { Edge e = new Edge(line); if (edges.Contains(e)) { continue; } edges.Add(e); } else { Line new_line = line.swapHandles(); center = new_line.getCenterPoint(); offset = new_line.getOffsetVector(); dir = line.getDirectionVector(); p = center.move(_Variables.MOVE_DISTANCE, offset); p = p.move(_Variables.MOVE_DISTANCE, dir); inSide = Region_Static.isPointinRegion(p, offset, contours); if (inSide) { Edge e = new Edge(new_line); if (edges.Contains(e)) { continue; } edges.Add(e); } else { throw new RegionLineNotInRegionException(); } } } }
public D_Raud(G.Line main, G.Line side1, G.Line side2, int nr, int d, string teras, int parand = 0) : base(main, nr, d, teras) { _A = shorter(side1.Length()); _B = shorter(main.Length()); _B2 = shorter(main.Length() + parand); // parand magic _C = shorter(side2.Length()); _IP = main.getCenterPoint(); _Length = _A + _B2 + _C; // parand magic G.Vector v1 = -1 * side1.getDirectionVector(); _Side1Point = _StartPoint.move(_A, v1); G.Vector v2 = side2.getDirectionVector(); _Side2Point = _EndPoint.move(_C, v2); }
public U_Raud(G.Line side1, int z_dist, int nr, int d, string teras) : base(side1, nr, d, teras) { if (d > 16) { _A = shorter(d * 14.5); } else { _A = shorter(d * 13); } _B = shorter(z_dist); _C = shorter(side1.Length()); _IP = side1.getCenterPoint(); _Length = _A + _B + _C; }
public E_Raud(G.Line main, G.Line side1, G.Line side2, int nr, int d, string teras, int parand = 0) : base(main, nr, d, teras) { G.Vector mainDir = main.getDirectionVector(); G.Polar mainPol = G.Converter.xy_to_la(mainDir); G.Vector sideDir1 = side1.getDirectionVector(); G.Polar sidePol1 = G.Converter.xy_to_la(sideDir1); G.Vector sideDir2 = side2.getDirectionVector(); G.Polar sidePol2 = G.Converter.xy_to_la(sideDir2); _A = shorter(side1.Length()); _B = shorter(main.Length()); _B2 = shorter(main.Length() + parand); // parand magic _C = shorter(side2.Length()); G.Vector perpendVector = mainDir.rotate(-Math.PI / 2); double maxDist = Math.Max(_A, _C) * 2; G.Line mainExtended = main.extendDouble(maxDist); G.Point movePoint1 = side1.Start.move(maxDist, perpendVector); G.Line perpendLine1 = new G.Line(side1.Start, movePoint1); G.Point interPoint1 = G.Line.getIntersectionPoint(mainExtended, perpendLine1); G.Line XLine = new G.Line(side1.Start, interPoint1); G.Point movePoint2 = side2.End.move(maxDist, perpendVector); G.Line perpendLine2 = new G.Line(side2.End, movePoint2); G.Point interPoint2 = G.Line.getIntersectionPoint(mainExtended, perpendLine2); G.Line YLine = new G.Line(side2.End, interPoint2); _U = G.Converter.AngleDelta(mainPol.angle, sidePol1.angle); _V = G.Converter.AngleDelta(mainPol.angle, sidePol2.angle); _X = XLine.Length(); _Y = YLine.Length(); _IP = main.getCenterPoint(); _Length = _A + _B2 + _C; // parand magic G.Vector v1 = -1 * side1.getDirectionVector(); _Side1Point = _StartPoint.move(_A, v1); G.Vector v2 = side2.getDirectionVector(); _Side2Point = _EndPoint.move(_C, v2); }
private bool narrow_denier(G.Edge e) { G.Line main = e.Line.Copy(); G.Vector v1 = main.getOffsetVector(); G.Point cp = main.getCenterPoint(); G.Point ep1 = main.Start.move(_V_.X_CONCRETE_COVER_1 * 2, v1); G.Point ep2 = cp.move(_V_.X_CONCRETE_COVER_1 * 2, v1); G.Point ep3 = main.End.move(_V_.X_CONCRETE_COVER_1 * 2, v1); G.Line testLine1 = new G.Line(main.Start, ep1); G.Line testLine2 = new G.Line(cp, ep2); G.Line testLine3 = new G.Line(main.End, ep3); if (denier(testLine1, e) && denier(testLine2, e) && denier(testLine3, e)) { return(true); } return(false); }