/// <summary> /// Construct Edge of line type by points and normal (localY). /// </summary> public Edge(FdPoint3d startPoint, FdPoint3d endPoint, FdVector3d localY) { this.Type = "line"; this.Points.Add(startPoint); this.Points.Add(endPoint); this.Normal = localY; }
public bool Equals(FdPoint3d p) { if ((object)p == null) { return(false); } return((X == p.X) && (Y == p.Y) && (Z == p.Z)); }
public bool Equals(FdPoint3d p, double tolerance) { if ((object)p == null) { return(false); } return((Math.Abs(X - p.X) < tolerance) && (Math.Abs(Y - p.Y) < tolerance) && (Math.Abs(Z - p.Z) < tolerance)); }
/// <summary> /// /// Create FdCoordinateSystem from Dynamo coordinate system of a Arc or Circle. /// Dynamo Arcs and Circles follow left-hand rule. /// This method realignes the coordinate system. /// </summary> internal static FdCoordinateSystem FromDynamoCoordinateSystemArcOrCircle(Autodesk.DesignScript.Geometry.CoordinateSystem obj) { FdPoint3d origin = FdPoint3d.FromDynamo(obj.Origin); FdVector3d localX = FdVector3d.FromDynamo(obj.YAxis); FdVector3d localY = FdVector3d.FromDynamo(obj.XAxis); FdVector3d localZ = localX.Cross(localY).Normalize(); return(new FdCoordinateSystem(origin, localX, localY, localZ)); }
/// <summary> /// Create FdCoordinateSystem from Dynamo coordinate system of a Surface. /// No realignment neccessary. /// </summary> internal static FdCoordinateSystem FromDynamoCoordinateSystemSurface(Autodesk.DesignScript.Geometry.CoordinateSystem obj) { FdPoint3d origin = FdPoint3d.FromDynamo(obj.Origin); FdVector3d localX = FdVector3d.FromDynamo(obj.XAxis); FdVector3d localY = FdVector3d.FromDynamo(obj.YAxis); FdVector3d localZ = FdVector3d.FromDynamo(obj.ZAxis); return(new FdCoordinateSystem(origin, localX, localY, localZ)); }
/// <summary> /// Create Edge (Line) from Dynamo NurbsCurve. /// </summary> public static Geometry.Edge FromDynamoLinearNurbsCurve(Autodesk.DesignScript.Geometry.NurbsCurve obj) { FdPoint3d startPoint = FdPoint3d.FromDynamo(obj.StartPoint); FdPoint3d endPoint = FdPoint3d.FromDynamo(obj.EndPoint); // lcs FdCoordinateSystem cs = FdCoordinateSystem.FromDynamoCurve(obj); // return return(new Geometry.Edge(startPoint, endPoint, cs)); }
/// <summary> /// Create Edge (Circle) from Dynamo Circle. /// </summary> public static Geometry.Edge FromDynamoCircle(Autodesk.DesignScript.Geometry.Circle obj) { double radius = obj.Radius; FdPoint3d centerPoint = FdPoint3d.FromDynamo(obj.CenterPoint); // lcs FdCoordinateSystem cs = FdCoordinateSystem.FromDynamoCurve(obj); // return return(new Geometry.Edge(radius, centerPoint, cs)); }
/// <summary> /// Create Edge (Arc2) from Dynamo Arc. /// Used for bar definition. /// </summary> public static Geometry.Edge FromDynamoArc2(Autodesk.DesignScript.Geometry.Arc obj) { FdPoint3d p0 = FdPoint3d.FromDynamo(obj.StartPoint); FdPoint3d p1 = FdPoint3d.FromDynamo(obj.PointAtParameter(0.5)); FdPoint3d p2 = FdPoint3d.FromDynamo(obj.EndPoint); // lcs FdCoordinateSystem cs = FdCoordinateSystem.FromDynamoCurve(obj); // return return(new Geometry.Edge(p0, p1, p2, cs)); }
/// <summary> /// Create Edge (Arc1) from Dynamo Arc. /// </summary> public static Geometry.Edge FromDynamoArc1(Autodesk.DesignScript.Geometry.Arc obj) { double radius = obj.Radius; double startAngle = 0; double endAngle = startAngle + Degree.ToRadians(obj.SweepAngle); FdPoint3d centerPoint = FdPoint3d.FromDynamo(obj.CenterPoint); FdVector3d xAxis = new FdVector3d(centerPoint, FdPoint3d.FromDynamo(obj.StartPoint)).Normalize(); // lcs FdCoordinateSystem cs = FdCoordinateSystem.FromDynamoCurve(obj); // return return(new Geometry.Edge(radius, startAngle, endAngle, centerPoint, xAxis, cs)); }
public override bool Equals(System.Object obj) { if (obj == null) { return(false); } FdPoint3d p = obj as FdPoint3d; if ((System.Object)p == null) { return(false); } return((X == p.X) && (Y == p.Y) && (Z == p.Z)); }
/// <summary> /// Construct FdCoordinateSystem from origin point and local x, y, z axes. /// </summary> public FdCoordinateSystem(FdPoint3d origin, FdVector3d localX, FdVector3d localY, FdVector3d localZ) { this.Origin = origin; this._localX = localX; this._localY = localY; this._localZ = localZ; if (!this.IsComplete()) { throw new System.ArgumentException("The defined coordinate system is not complete!"); } if (!this.IsOrthogonal()) { throw new System.ArgumentException($"The defined coordinate system is not orthogonal within the tolerance {Tolerance.DotProduct}"); } }
/// <summary> /// Create region by points and coordinate system. /// </summary> /// <param name="points">List of sorted points defining the outer perimeter of the region.</param> /// <param name="coordinateSystem">Coordinate system of the region</param> public Region(List <FdPoint3d> points, FdCoordinateSystem coordinateSystem) { // edge normal FdVector3d edgeLocalY = coordinateSystem.LocalZ; List <Edge> edges = new List <Edge>(); for (int idx = 0; idx < points.Count; idx++) { // startPoint FdPoint3d p0 = p0 = points[idx]; // endPoint FdPoint3d p1; if (idx != points.Count - 1) { p1 = points[idx + 1]; } else { p1 = points[0]; } // create edge edges.Add(new Edge(p0, p1, edgeLocalY)); } // create contours Contour contour = new Contour(edges); // set properties this.Contours = new List <Contour> { contour }; this.CoordinateSystem = coordinateSystem; }
/// <summary> /// Create FdPoint3d from Dynamo point. /// </summary> public static FdPoint3d FromDynamo(Autodesk.DesignScript.Geometry.Point point) { FdPoint3d newPoint = new FdPoint3d(point.X, point.Y, point.Z); return(newPoint); }
/// <summary> /// Construct FdVector3d by start and end points. /// </summary> /// <param name="p0">Start point</param> /// <param name="p1">End point</param> public FdVector3d(FdPoint3d p0, FdPoint3d p1) { this.X = p1.X - p0.X; this.Y = p1.Y - p0.Y; this.Z = p1.Z - p0.Z; }
internal static Rhino.Geometry.Point3d ToRhino(this FemDesign.Geometry.FdPoint3d point) { return(new Rhino.Geometry.Point3d(point.X, point.Y, point.Z)); }
/// <summary> /// Construct LineSegment from start and endpoint. /// </summary> /// <param name="verticies"></param> public LineSegment(FdPoint3d start, FdPoint3d end) { this.StartPoint = start; this.BasePoint = new FdPoint3d((start.X + end.X) / 2.0, (start.Y + end.Y) / 2.0, (start.Z + end.Z) / 2.0); this.EndPoint = end; }
/// <summary> /// Global coordinate system /// </summary> public static FdCoordinateSystem Global() { return(new FdCoordinateSystem(FdPoint3d.Origin(), FdVector3d.UnitX(), FdVector3d.UnitY())); }