private static Polygon _makeRectangle(Vector baseSegment, Distance height, Direction referencePlaneNormal) { if (referencePlaneNormal == null) { referencePlaneNormal = Direction.Out; } Direction heightDirection = referencePlaneNormal.CrossProduct(baseSegment.Direction); var heightVector = new Vector(heightDirection, height); Polygon polygon = Parallelogram(baseSegment, heightVector); return polygon; }
private static Shift GetRotation(Direction normal) { if (normal.IsParallelTo(Direction.Out)) { return Rotation.Identity; } var angle = normal.AngleBetween(Direction.Out); var axis = new Line(normal.CrossProduct(Direction.Out)); var rotation = new Shift(new Rotation(axis, angle)); return rotation; }
public Arc(Point basePoint, Point endPoint, Direction initialDirection) { this.BasePoint = basePoint; this.EndPoint = endPoint; if (this.IsClosed) { throw new GeometricException("Not enough information given to determine curvature."); } var segmentBetweenPoints = new LineSegment(basePoint,endPoint); this.NormalDirection = initialDirection.CrossProduct(segmentBetweenPoints.Direction); var plane1 = new Plane(BasePoint, initialDirection); var plane2 = new Plane(segmentBetweenPoints.MidPoint, segmentBetweenPoints.Direction); var intersectingLine = plane1.IntersectWithPlane(plane2); var containingPlane = new Plane(BasePoint, NormalDirection); var centerPoint = intersectingLine.IntersectWithPlane(containingPlane); this.CenterPoint = centerPoint; //var line1 = new Line(BasePoint, NormalDirection.CrossProduct(initialDirection)); //var line2 = new Line(segmentBetweenPoints.MidPoint, NormalDirection.CrossProduct(segmentBetweenPoints.Direction)); //this._centerPoint = line1.IntersectWithLine(line2); }