public static Dictionary <string, object> CurveSinusoidalPoints( Autodesk.DesignScript.Geometry.Curve _Curve, double WaveLength = 5.0, double Amplitude = 1.0, double Resolution = 2.0) { double n = (_Curve.Length / WaveLength) * 4 * Resolution; double _Span = _Curve.Length / n; List <Autodesk.DesignScript.Geometry.Point> points = new List <Autodesk.DesignScript.Geometry.Point>(); List <double> ks = new List <double>(); for (int i = 0; i < n; i++) { double k = Amplitude * Math.Sin(i * _Span * Math.PI * 2 / WaveLength + Math.PI * 2); Autodesk.DesignScript.Geometry.Plane pl = _Curve.PlaneAtParameter(_Curve.ParameterAtSegmentLength(i * _Span)); Autodesk.DesignScript.Geometry.Point p = _Curve.PointAtSegmentLength(i * _Span); points.Add((Autodesk.DesignScript.Geometry.Point)p.Translate(pl.YAxis, k)); ks.Add(k); } return(new Dictionary <string, object> { { "Points", points }, { "k", ks } }); }
public static Dictionary <string, object> CurveSinusoidalPointsWithVoxel( Autodesk.DesignScript.Geometry.Curve _Curve, VoxelImage Voxel, double WaveLength = 5.0, double Amplitude = 1.0, double Resolution = 2.0) { VoxelChannel _VoxelChannel = Voxel.GetChannel(VoxelImageLayout.SHAPECHANNEL); double n = (_Curve.Length / WaveLength) * 4 * Resolution; double _Span = _Curve.Length / n; List <Autodesk.DesignScript.Geometry.Point> points = new List <Autodesk.DesignScript.Geometry.Point>(); List <double> ks = new List <double>(); for (int i = 0; i < n; i++) { Autodesk.DesignScript.Geometry.Plane pl = _Curve.PlaneAtParameter(_Curve.ParameterAtSegmentLength(i * _Span)); Autodesk.DesignScript.Geometry.Point p = _Curve.PointAtSegmentLength(i * _Span); double FieldValue = V2GVoxel.GetVoxelFieldValue(_VoxelChannel, p.X, p.Y, p.Z); double k = FieldValue * Amplitude * Math.Sin(i * _Span * Math.PI * 2 / WaveLength + Math.PI * 2); points.Add((Autodesk.DesignScript.Geometry.Point)p.Translate(pl.YAxis, k)); ks.Add(k); } return(new Dictionary <string, object> { { "Points", points }, { "k", ks } }); }
Geo.Point GetMemberPointOnEdge(int faceIndex, int edgeIndex, bool rightHand) { int direction; if (rightHand) { direction = 1; } else { direction = -1; } hVertex v1 = mesh.faces[faceIndex].vertices[edgeIndex]; hVertex v2 = mesh.faces[faceIndex].vertices[(edgeIndex + 1) % 4]; Geo.Point midPoint = Geo.Point.ByCoordinates((v1.x + v2.x) / 2, (v1.y + v2.y) / 2, (v1.z + v2.z) / 2); Geo.Vector move = Geo.Vector.ByTwoPoints(v1.ToPoint(), v2.ToPoint()); move = move.Normalized(); move = move.Scale(offset * direction); var returnPt = (Geo.Point)midPoint.Translate(move); // Dispose /*{ * midPoint.Dispose(); * move.Dispose(); * }*/ return(returnPt); }
private static ILineEntity ByStartPointDirectionLengthCore(Point startPt, Vector direction, double length) { if (startPt == null) { throw new ArgumentNullException("startPt"); } else if (direction == null) { throw new ArgumentNullException("direction"); } else if (direction.IsZeroVector() || length == 0.0) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "direction")); } else if (length == 0.0) { throw new ArgumentException(Properties.Resources.IsZeroLength); } //Temporary end point is created by translating, should be disposed Vector offset = direction.Normalize().MultiplyBy(length); var endPt = startPt.Translate(offset, false); ILineEntity entity = HostFactory.Factory.LineByStartPointEndPoint(startPt.PointEntity, endPt.PointEntity); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "Line.ByStartPointDirectionLength")); } return(entity); }
/// <summary> /// Create a Reference Point Element offset from a point along a vector /// </summary> /// <param name="basePoint"></param> /// <param name="direction"></param> /// <param name="distance"></param> /// <returns></returns> public static ReferencePoint ByPointVectorDistance(Point basePoint, Vector direction, double distance) { if (!Document.IsFamilyDocument) { throw new Exception("ReferencePoint Elements can only be created in a Family Document"); } if (basePoint == null) { throw new ArgumentNullException("basePoint"); } if (direction == null) { throw new ArgumentNullException("direction"); } var pt = (Point)basePoint.Translate(direction.Scale(distance)); return(new ReferencePoint(pt.ToXyz())); }
/// <summary> /// Create a Reference Point Element offset from a point along a vector /// </summary> /// <param name="basePoint"></param> /// <param name="direction"></param> /// <param name="distance"></param> /// <returns></returns> public static ReferencePoint ByPointVectorDistance(Point basePoint, Vector direction, double distance) { if (!Document.IsFamilyDocument) { throw new Exception(Properties.Resources.ReferencePointCreationFailure); } if (basePoint == null) { throw new ArgumentNullException("basePoint"); } if (direction == null) { throw new ArgumentNullException("direction"); } var pt = (Point)basePoint.Translate(direction.Scale(distance)); return(new ReferencePoint(pt.ToXyz())); }
private static ILineEntity ByStartPointDirectionLengthCore(Point startPt, Vector direction, double length) { if (startPt == null) { throw new ArgumentNullException("startPt"); } else if (direction == null) { throw new ArgumentNullException("direction"); } else if (direction.IsZeroVector() || length == 0.0) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "direction")); } else if (length == 0.0) { throw new ArgumentException(Properties.Resources.IsZeroLength); } //Temporary end point is created by translating, should be disposed Vector offset = direction.Normalize().MultiplyBy(length); var endPt = startPt.Translate(offset, false); ILineEntity entity = HostFactory.Factory.LineByStartPointEndPoint(startPt.PointEntity, endPt.PointEntity); if (null == entity) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "Line.ByStartPointDirectionLength")); return entity; }
/// <summary> /// Create a Reference Point Element offset from a point along a vector /// </summary> /// <param name="basePoint"></param> /// <param name="direction"></param> /// <param name="distance"></param> /// <returns></returns> public static ReferencePoint ByPointVectorDistance(Point basePoint, Vector direction, double distance) { if (!Document.IsFamilyDocument) { throw new Exception("ReferencePoint Elements can only be created in a Family Document"); } if (basePoint == null) { throw new ArgumentNullException("basePoint"); } if (direction == null) { throw new ArgumentNullException("direction"); } var pt = (Point) basePoint.Translate(direction.Scale(distance)); return new ReferencePoint(pt.ToXyz()); }