public void Arc_Tilted() { var p1 = Point.ByCoordinates(4.3957, 7.96146, 0); var p2 = Point.ByCoordinates(6.49355, 5.98396, 2.28352); var p3 = Point.ByCoordinates(7.11897, 2.70101, 3.81878); var arc = Arc.ByThreePoints(p1, p2, p3); var revitCurve = arc.ToRevitType(false); Assert.NotNull(revitCurve); Assert.IsAssignableFrom <Autodesk.Revit.DB.Arc>(revitCurve); var revitArc = (Autodesk.Revit.DB.Arc)revitCurve; revitArc.Center.X.ShouldBeApproximately(2, 0.0001); revitArc.Center.Y.ShouldBeApproximately(2, 0.0001); revitArc.Center.Z.ShouldBeApproximately(0, 0.0001); arc.CenterPoint.ShouldBeApproximately(revitArc.Center.ToPoint(false)); arc.Radius.ShouldBeApproximately(revitArc.Radius); Math.Abs(arc.Normal.Dot(revitArc.Normal.ToVector())).ShouldBeApproximately(1); }
public static Arc GetAsArc(this Curve curve) { if (curve.IsClosed) { throw new ArgumentException("Curve is closed, cannot be an Arc"); } using (Point midPoint = curve.PointAtParameter(0.5)) { return(Arc.ByThreePoints(curve.StartPoint, midPoint, curve.EndPoint)); } }
public static bool IsArc(this Curve curve) { if (curve.IsClosed) { return(false); } using (Point midPoint = curve.PointAtParameter(0.5)) using (Arc arc = Arc.ByThreePoints(curve.StartPoint, midPoint, curve.EndPoint)) { return(Threshold(arc.Length, curve.Length)); } }
public static Surface SetupArcLoft() { var pt1 = Point.ByCoordinates(0, 0, 4); var pt2 = Point.ByCoordinates(1, 1, 4); var pt3 = Point.ByCoordinates(0, 4, 4); var pt4 = Point.ByCoordinates(0, 0, 0); var pt5 = Point.ByCoordinates(2, 2, 0); var pt6 = Point.ByCoordinates(0, 4, 0); var top = Arc.ByThreePoints(pt1, pt2, pt3); var bottom = Arc.ByThreePoints(pt4, pt5, pt6); var surface = Surface.ByLoft(new List <Curve>() { top, bottom }); return(surface); }
public static Surface SetupArcCurveSweep() { var pt1 = Point.ByCoordinates(0, 0, 0); var pt2 = Point.ByCoordinates(0, 0, 5); var pt3 = Point.ByCoordinates(10, 0, 0); var pt4 = Point.ByCoordinates(-5, 5, 0); var pt5 = Point.ByCoordinates(0, 10, 0); var pt6 = Point.ByCoordinates(5, 10, 10); var pt7 = Point.ByCoordinates(15, 15, 0); var rail1 = Arc.ByThreePoints(pt5, pt6, pt7); var rail2 = Arc.ByThreePoints(pt1, pt2, pt3); var profile = Arc.ByThreePoints(pt1, pt4, pt5); var surface = Surface.BySweep2Rails(rail1, rail2, profile); return(surface); }
private Curve CreateCurve(TwoCurves compareTo, Point A, Point B, double parameter, Point refpoint) { // Init an empty curve Curve returnValue = null; // If the boundaries to compare this curve to are arcs // create a middle line between the boundaries if (compareTo.Curve1.IsArc() || compareTo.Curve2.IsArc()) { Line line = Line.ByStartPointEndPoint(compareTo.Curve1.PointAtParameter(0.5), compareTo.Curve2.PointAtParameter(0.5)); // If the reference point is on curve 2 invert the parameter if (compareTo.Curve1.ClosestPointTo(refpoint).DistanceTo(refpoint) > 0) { parameter = 1 - parameter; } try { // try to create an arc by three points returnValue = Arc.ByThreePoints(A, line.PointAtParameter(parameter), B); } catch (System.ApplicationException) { // On error create a line from A to B returnValue = Line.ByStartPointEndPoint(A, B); } } else { // If the boundaries are lines, create a line from A to B returnValue = Line.ByStartPointEndPoint(A, B); } return(returnValue); }