public PerpConstructionLines(PartEntity part, Vector2 line1End, Vector2 line1Start, Vector2 GivenLine1End, Vector2 GivenLine2End, float length, PerpendicularRotation rotation, EntityType type) { this.PartEntity = part; this.EndOfLine = line1End; this.StartOfLine = line1Start; this.GivenLine1End = GivenLine1End; this.GivenLine2End = GivenLine2End; this.LinesLength = length; this.Rotation = rotation; this.EntityType = type; this.UseBezierControlPointsAsRefForLine1 = true; this.UseBezierControlPointsAsRefForLine2 = true; Vector2 given1; Vector2 given2; if (PartEntity != null && PartEntity is PartEntityBezier) { if (UseBezierControlPointsAsRefForLine1) { GivenLine1End = StartOfLine + ((PartEntityBezier)PartEntity).Control1; } if (UseBezierControlPointsAsRefForLine2) { GivenLine2End = EndOfLine + ((PartEntityBezier)PartEntity).Control2; } } given1 = GivenLine1End - StartOfLine; given2 = EndOfLine - GivenLine2End; if (Rotation == PerpendicularRotation.Clockwise) { PerpEndPointStartLine = new Vector2(given1.Y, -given1.X);//clockwise } else { PerpEndPointStartLine = new Vector2(-given1.Y, given1.X);//anticlockwise } if (Rotation == PerpendicularRotation.Clockwise) { PerpEndPointEndLine = new Vector2(given2.Y, -given2.X);//clockwise } else { PerpEndPointEndLine = new Vector2(-given2.Y, given2.X);//anticlockwise } PerpEndPointStartLine = Vector2.Normalize(PerpEndPointStartLine) * LinesLength; PerpEndPointEndLine = Vector2.Normalize(PerpEndPointEndLine) * LinesLength; }
public List <PerpConstructionLines> AddDefaultSAConstructionLines(float length, PerpendicularRotation rotation, EntityType type) { List <PerpConstructionLines> listOfPerpPoints = new List <PerpConstructionLines>(); List <PartEntity> filtered = GetNormalEntitys(); for (int i = 0; i < filtered.Count; i++) { PartEntity first = filtered[i]; PartEntity second; if (i + 1 < filtered.Count) { second = filtered[i + 1]; } else { second = filtered[0]; } PerpConstructionLines pcl = new PerpConstructionLines(second, second.End, first.End, second.End, first.End, length, rotation, type); listOfPerpPoints.Add(pcl); } return(listOfPerpPoints); }