public Rhino.Commands.Result GetPoints(Rhino.RhinoDoc doc) { // Input interval var input = new Rhino.Input.Custom.GetNumber(); // Select surface var go = new Rhino.Input.Custom.GetObject(); go.SetCommandPrompt("Select point"); go.GeometryFilter = Rhino.DocObjects.ObjectType.Point; go.GetMultiple(1, 1); Rhino.Geometry.Point pt = go.Object(0).Point(); Rhino.Geometry.Point3d pointA = pt.Location; go.SetCommandPrompt("Select surface"); go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface; go.GetMultiple(1, 1); Rhino.Geometry.Surface surfaceB = go.Object(0).Surface(); double u, v; if (surfaceB.ClosestPoint(pointA, out u, out v)) { Rhino.Geometry.Point3d pointC = surfaceB.PointAt(u, v); Rhino.Geometry.Vector3d vector = pointA - pointC; // write list pointD } return(Rhino.Commands.Result.Success); }
private static Rhino.Geometry.Vector3f CreateVector(ZSegment Segment) { Rhino.Geometry.Point3d startPoint = new Rhino.Geometry.Point3d(Segment.p1.x, Segment.p1.y, Segment.p1.z); Rhino.Geometry.Point3d endPoint = new Rhino.Geometry.Point3d(Segment.p2.x, Segment.p2.y, Segment.p2.z); Rhino.Geometry.Vector3d vect = endPoint - startPoint; return(new Rhino.Geometry.Vector3f((float)vect.X, (float)vect.Y, (float)vect.Z)); }
public static Rhino.Commands.Result AddLine(Rhino.RhinoDoc doc) { Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint(); gp.SetCommandPrompt("Start of line"); gp.Get(); if (gp.CommandResult() != Rhino.Commands.Result.Success) { return(gp.CommandResult()); } Rhino.Geometry.Point3d pt_start = gp.Point(); gp.SetCommandPrompt("End of line"); gp.SetBasePoint(pt_start, false); gp.DrawLineFromPoint(pt_start, true); gp.Get(); if (gp.CommandResult() != Rhino.Commands.Result.Success) { return(gp.CommandResult()); } Rhino.Geometry.Point3d pt_end = gp.Point(); Rhino.Geometry.Vector3d v = pt_end - pt_start; if (v.IsTiny(Rhino.RhinoMath.ZeroTolerance)) { return(Rhino.Commands.Result.Nothing); } if (doc.Objects.AddLine(pt_start, pt_end) != Guid.Empty) { doc.Views.Redraw(); return(Rhino.Commands.Result.Success); } return(Rhino.Commands.Result.Failure); }
public bool Cone(int index, ref Rhino.Geometry.Cone cone, ref Rhino.Geometry.Plane truncation) { Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d(); double height = 0.0; double radius = 0.0; Rhino.Geometry.Point3d t_origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d t_xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d t_yaxis = new Rhino.Geometry.Vector3d(); if (UnsafeNativeMethods.Rdk_CustomMeshes_Cone(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref height, ref radius, ref t_origin, ref t_xaxis, ref t_yaxis)) { cone = new Rhino.Geometry.Cone(new Rhino.Geometry.Plane(origin, xaxis, yaxis), height, radius); truncation = new Rhino.Geometry.Plane(t_origin, t_xaxis, t_yaxis); return(true); } return(false); }
public int[] Sort(Rhino.Geometry.Vector3d cameraDirection) { DirectedOrder d = null; var node = m_order.First; while (node != null) { if (node.Value.Direction.IsParallelTo(cameraDirection, SortAngleTolerance) == 1) { // move node to head to keep at top of MRU cache m_order.Remove(node); m_order.AddFirst(node); return(node.Value.Indices); } d = node.Value; node = node.Next; } if (d == null || m_order.Count < MaximumCachedSortLists) { d = new DirectedOrder(m_points.Length); } m_camera_vector = cameraDirection; int[] indices = d.Indices; Array.Sort(indices, IndexComparison); d.Direction = cameraDirection; m_order.AddFirst(d); if (m_order.Count > MaximumCachedSortLists) { m_order.RemoveLast(); } return(indices); }
/// <summary> /// Spherical linear interpolator /// </summary> public static Rhino.Geometry.Vector3d Slerp(Rhino.Geometry.Vector3d v0, Rhino.Geometry.Vector3d v1, double n) { if (n <= 0.0) { return(v0); } if (v0 == v1 || n >= 1.0) { return(v1); } Rhino.Geometry.Vector3d u0 = new Rhino.Geometry.Vector3d(v0); Rhino.Geometry.Vector3d u1 = new Rhino.Geometry.Vector3d(v1); u0.Unitize(); u1.Unitize(); double dot = Rhino.Geometry.Vector3d.Multiply(u0, u1); dot = ((dot) < (-1.0) ? (-1.0) : ((dot) > (1.0) ? (1.0) : (dot))); double theta = Math.Acos(dot); if (Math.Abs(theta) < Double.Epsilon) { return(v1); } double st = Math.Sin(theta); return((v0 * ((Math.Sin((1.0 - n) * theta)) / st)) + (v1 * ((Math.Sin(n * theta) / st)))); }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <returns></returns> public Rhino.Geometry.Vector3d VectorTo(Rhino.Geometry.Point3d point) { MyPlugInSdk.SdkTest(true); Rhino.Geometry.Point3d from = new Rhino.Geometry.Point3d(m_x, m_y, m_z); Rhino.Geometry.Vector3d rc = new Rhino.Geometry.Vector3d(); UnsafeNativeMethods.Expose_CreateVector(from, point, ref rc); return(rc); }
private static Rhino.Geometry.NurbsCurve GetSpirial0() { var axisStart = new Rhino.Geometry.Point3d(0, 0, 0); var axisDir = new Rhino.Geometry.Vector3d(1, 0, 0); var radiusPoint = new Rhino.Geometry.Point3d(0, 1, 0); return(Rhino.Geometry.NurbsCurve.CreateSpiral(axisStart, axisDir, radiusPoint, 1, 10, 1.0, 1.0)); }
private static Rhino.Geometry.NurbsCurve GetSpirial0() { var axisStart = new Rhino.Geometry.Point3d(0, 0, 0); var axisDir = new Rhino.Geometry.Vector3d(1, 0, 0); var radiusPoint = new Rhino.Geometry.Point3d(0, 1, 0); return Rhino.Geometry.NurbsCurve.CreateSpiral(axisStart, axisDir, radiusPoint, 1, 10, 1.0, 1.0); }
static public Rhino.Geometry.Vector3d CrossProduct(Rhino.Geometry.Vector3d u, Rhino.Geometry.Vector3d v) { Rhino.Geometry.Vector3d z = new Rhino.Geometry.Vector3d(); z.X = u.Y * v.Z - u.Z * v.Y; z.Y = -u.X * v.Z + u.Z * v.X; z.Z = u.X * v.Y - u.Y * v.X; return(z); }
public static Rhino.Commands.Result MoveGripObjects(Rhino.RhinoDoc doc) { // The following example demonstrates how to move a surface's grip objects. // In this sample, all grips will be moved a fixed distance of 0.5 units // in the normal direction of the surface at that grip location. Rhino.DocObjects.ObjRef objRef; Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select surface for control point editing", false, Rhino.DocObjects.ObjectType.Surface, out objRef); if (rc != Rhino.Commands.Result.Success) { return(rc); } Rhino.DocObjects.RhinoObject obj = objRef.Object(); if (null == obj) { return(Rhino.Commands.Result.Failure); } Rhino.Geometry.Surface srf = objRef.Surface(); if (null == srf) { return(Rhino.Commands.Result.Failure); } // Make sure the object's grips are enabled obj.GripsOn = true; doc.Views.Redraw(); Rhino.DocObjects.GripObject[] grips = obj.GetGrips(); for (int i = 0; i < grips.Length; i++) { Rhino.DocObjects.GripObject grip = grips[i]; // Calculate the point on the surface closest to our test point, // which is the grip's 3-D location (for this example). double u, v; if (srf.ClosestPoint(grip.CurrentLocation, out u, out v)) { // Compute the surface normal at a point Rhino.Geometry.Vector3d dir = srf.NormalAt(u, v); dir.Unitize(); // Scale by our fixed distance dir *= 0.5; // Move the grip to a new location grip.Move(dir); } } // Altered grip positions on a RhinoObject are used to calculate an updated // object that is added to the document. doc.Objects.GripUpdate(obj, false); doc.Views.Redraw(); return(Rhino.Commands.Result.Success); }
public static Rhino.Commands.Result ConstrainedCopy(Rhino.RhinoDoc doc) { // Get a single planar closed curve var go = new Rhino.Input.Custom.GetObject(); go.SetCommandPrompt("Select curve"); go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; go.GeometryAttributeFilter = Rhino.Input.Custom.GeometryAttributeFilter.ClosedCurve; go.Get(); if (go.CommandResult() != Rhino.Commands.Result.Success) { return(go.CommandResult()); } var objref = go.Object(0); var base_curve = objref.Curve(); var first_point = objref.SelectionPoint(); if (base_curve == null || !first_point.IsValid) { return(Rhino.Commands.Result.Cancel); } Rhino.Geometry.Plane plane; if (!base_curve.TryGetPlane(out plane)) { return(Rhino.Commands.Result.Cancel); } // Get a point constrained to a line passing through the initial selection // point and parallel to the plane's normal var gp = new Rhino.Input.Custom.GetPoint(); gp.SetCommandPrompt("Offset point"); gp.DrawLineFromPoint(first_point, true); var line = new Rhino.Geometry.Line(first_point, first_point + plane.Normal); gp.Constrain(line); gp.Get(); if (gp.CommandResult() != Rhino.Commands.Result.Success) { return(gp.CommandResult()); } var second_point = gp.Point(); Rhino.Geometry.Vector3d vec = second_point - first_point; if (vec.Length > 0.001) { var xf = Rhino.Geometry.Transform.Translation(vec); Guid id = doc.Objects.Transform(objref, xf, false); if (id != Guid.Empty) { doc.Views.Redraw(); return(Rhino.Commands.Result.Success); } } return(Rhino.Commands.Result.Cancel); }
static public bool CreateSections(Rhino.RhinoDoc doc, Rhino.Geometry.GeometryBase geo, Rhino.Geometry.Surface surfaceB, Rhino.Geometry.Curve curve, double interval, ref List <PlanePoint> points) { Rhino.Geometry.Interval domain = curve.Domain; // fixed issue for (double t = domain.T0; t < domain.T1; t += interval) { Rhino.Geometry.Point3d pt = curve.PointAt(t); Rhino.Geometry.Vector3d tangent = curve.TangentAt(t); Rhino.Geometry.Vector3d curvature = curve.CurvatureAt(t); Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(); curve.FrameAt(t, out plane); doc.Objects.AddPoint(pt); curvature = curvature * 10.0; Rhino.Geometry.Line line = new Rhino.Geometry.Line(pt, curvature); doc.Objects.AddLine(line); RhinoApp.WriteLine("Curve at {0}", t); Rhino.Geometry.Vector3d normal = new Rhino.Geometry.Vector3d(); bool ret = false; if (geo is Rhino.Geometry.Brep) { Rhino.Geometry.Brep brepA = (Rhino.Geometry.Brep)geo; ret = GetNormalVector(brepA, pt, ref normal); RhinoApp.WriteLine(" Added Brep point at ({0}, {0}, {0})", pt.X, pt.Y, pt.Z); } else if (geo is Rhino.Geometry.Surface) { Rhino.Geometry.Surface surfaceA = (Rhino.Geometry.Surface)geo; ret = GetNormalVector(surfaceA, pt, ref normal); RhinoApp.WriteLine(" Added surface point at ({0}, {0}, {0})", pt.X, pt.Y, pt.Z); } if (ret) { Rhino.Geometry.Vector3d ucoord = CrossProduct(tangent, normal); Rhino.Geometry.Plane plane2 = new Rhino.Geometry.Plane(pt, ucoord, tangent); // normal); double[] parameters = plane2.GetPlaneEquation(); PlanePoint PlanePoint = new PlanePoint(); PlanePoint.pt = pt; PlanePoint.A = parameters[0]; PlanePoint.B = parameters[1]; PlanePoint.C = parameters[2]; PlanePoint.D = parameters[3]; PlanePoint.curvature = curvature; points.Add(PlanePoint); Rhino.Geometry.Interval Interval1 = new Rhino.Geometry.Interval(-0.1, -0.1); Rhino.Geometry.Interval Interval2 = new Rhino.Geometry.Interval(0.1, 0.1); Rhino.Geometry.PlaneSurface PlaneSurface = new Rhino.Geometry.PlaneSurface(plane2, Interval1, Interval2); doc.Objects.AddSurface(PlaneSurface); } } return(true); }
private void SetLocalVectors() { var tempX = new Rhino.Geometry.Vector3d(ePos.X - sPos.X, ePos.Y - sPos.Y, ePos.Z - sPos.Z); tempX.Unitize(); LocalX = tempX; LocalY = Rhino.Geometry.Vector3d.CrossProduct(elNormal, LocalX); }
/// <summary> /// Find the Perspective viewport in the 3dm file and sets up the default view. /// </summary> public void LoadCamera() { if (App.Manager.CurrentModel == null) { return; } Camera = new ViewportInfo(); bool cameraIsInitialized = false; int viewCount = App.Manager.CurrentModel.ModelFile.Views.Count; // find first perspective viewport projection in file if (viewCount > 0) { foreach (var view in App.Manager.CurrentModel.ModelFile.Views) { if (view.Viewport.IsPerspectiveProjection) { cameraIsInitialized = true; Camera = view.Viewport; Camera.TargetPoint = view.Viewport.TargetPoint; Camera.SetScreenPort(0, (int)View.Bounds.Size.Width, 0, (int)View.Bounds.Size.Height, 1, 1000); Camera.FrustumAspect = Camera.ScreenPortAspect; Camera.SetFrustumNearFar(App.Manager.CurrentModel.BBox); break; } } } // If there isn't one, then cook up a viewport from scratch... if (!cameraIsInitialized) { Camera.SetScreenPort(0, (int)View.Bounds.Size.Width, 0, (int)View.Bounds.Size.Height, 1, 1000); Camera.TargetPoint = new Rhino.Geometry.Point3d(0, 0, 0); var plane = new Rhino.Geometry.Plane(Rhino.Geometry.Point3d.Origin, new Rhino.Geometry.Vector3d(-1, -1, -1)); Camera.SetCameraLocation(new Rhino.Geometry.Point3d(10, 10, 10)); var dir = new Rhino.Geometry.Vector3d(-1, -1, -1); dir.Unitize(); Camera.SetCameraDirection(dir); Camera.SetCameraUp(plane.YAxis); Camera.SetFrustum(-1, 1, -1, 1, 0.1, 1000); Camera.FrustumAspect = Camera.ScreenPortAspect; Camera.IsPerspectiveProjection = true; Camera.Camera35mmLensLength = 50; if (App.Manager.CurrentModel != null) { if (App.Manager.CurrentModel.AllMeshes != null) { Camera.DollyExtents(App.Manager.CurrentModel.AllMeshes, 1.0); } } } }
public static bool IsBrepBox(Rhino.Geometry.Brep brep) { const double zero_tolerance = 1.0e-6; // or whatever bool rc = brep.IsSolid; if (rc) { rc = brep.Faces.Count == 6; } var N = new Rhino.Geometry.Vector3d[6]; for (int i = 0; rc && i < 6; i++) { Rhino.Geometry.Plane plane; rc = brep.Faces[i].TryGetPlane(out plane, zero_tolerance); if (rc) { N[i] = plane.ZAxis; N[i].Unitize(); } } for (int i = 0; rc && i < 6; i++) { int count = 0; for (int j = 0; rc && j < 6; j++) { double dot = Math.Abs(N[i] * N[j]); if (dot <= zero_tolerance) { continue; } if (Math.Abs(dot - 1.0) <= zero_tolerance) { count++; } else { rc = false; } } if (rc) { if (2 != count) { rc = false; } } } return(rc); }
public override void DrawViewportWires(Grasshopper.Kernel.IGH_PreviewArgs args) { if (Hidden) { return; } if (listArrow != null) { args.Display.DrawLines(listArrow, System.Drawing.Color.Red); } //eigenvectors if (crossCyan != null) { args.Display.DrawLines(crossCyan, System.Drawing.Color.Cyan); } if (crossMagenta != null) { args.Display.DrawLines(crossMagenta, System.Drawing.Color.Magenta); } foreach (var leaf in listLeaf) { if (leaf.forceSrf != null) { var srf = leaf.forceSrf.Duplicate() as Rhino.Geometry.NurbsSurface; //srf.Transform(zScale); args.Display.DrawSurface(srf, System.Drawing.Color.Aqua, 2); if (leaf.tuples != null) { foreach (var tup in leaf.tuples) { var P = leaf.formSrf.PointAt(tup.u, tup.v); var Q = leaf.forceSrf.PointAt(tup.u, tup.v); Rhino.Geometry.Vector3d D = new Rhino.Geometry.Vector3d(Q.X, Q.Y, Q.Z); D.Unitize(); D *= 0.3; args.Display.DrawLine(new Rhino.Geometry.Line(P, P + D), System.Drawing.Color.Magenta); } } } } foreach (var leaf in listLeaf) { /* if (leaf.shellSrf != null) { var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); }*/ } }
/// <summary> /// Rotates a viewport about an axis relative to a center point /// </summary> public static void RotateView(this ViewportInfo viewport, Rhino.Geometry.Vector3d axis, Rhino.Geometry.Point3d center, double angle) { Rhino.Geometry.Point3d cameraLocation = viewport.CameraLocation; Rhino.Geometry.Vector3d cameraY = viewport.CameraY; Rhino.Geometry.Vector3d cameraZ = viewport.CameraZ; Rhino.Geometry.Transform rotation = Rhino.Geometry.Transform.Rotation(angle, axis, center); cameraLocation = rotation * cameraLocation; cameraY = rotation * cameraY; cameraZ = -(rotation * cameraZ); viewport.SetCameraLocation(cameraLocation); viewport.SetCameraDirection(cameraZ); viewport.SetCameraUp(cameraY); }
/// <summary> /// Calculates the offsets (to be used later during transformation) /// </summary> public void CalculateOffsets() { ValidateOffsets(); Rhino.Geometry.Vector3d vx = Plane.XAxis; Rhino.Geometry.Vector3d vy = Plane.YAxis; Rhino.Geometry.Vector3d vz = Plane.ZAxis; if (DistanceX < 0) { vx.Reverse(); } if (DistanceY < 0) { vy.Reverse(); } if (DistanceZ < 0) { vz.Reverse(); } vx = vx * Math.Abs(DistanceX); vy = vy * Math.Abs(DistanceY); vz = vz * Math.Abs(DistanceZ); int index = 0; for (int z = 0; z < CountZ; z++) { for (int y = 0; y < CountY; y++) { for (int x = 0; x < CountX; x++) { if (x == 0 && y == 0 && z == 0) { Offsets[index++] = Rhino.Geometry.Vector3d.Zero; } else { Rhino.Geometry.Vector3d offset = new Rhino.Geometry.Vector3d( vx.X * (double)x + vy.X * (double)y + vz.X * (double)z, vx.Y * (double)x + vy.Y * (double)y + vz.Y * (double)z, vx.Z * (double)x + vy.Z * (double)y + vz.Z * (double)z ); Offsets[index++] = (offset.IsValid) ? offset : Rhino.Geometry.Vector3d.Zero; } } } } }
public bool Sphere(int index, ref Rhino.Geometry.Sphere sphere) { Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d(); double radius = 0.0; if (UnsafeNativeMethods.Rdk_CustomMeshes_Sphere(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref radius)) { sphere = new Rhino.Geometry.Sphere(new Rhino.Geometry.Plane(origin, xaxis, yaxis), radius); return(true); } return(false); }
/// <summary> /// Sets the viewport's camera location, target and up vector /// </summary> public static void SetTarget(this ViewportInfo viewport, Rhino.Geometry.Point3d targetLocation, Rhino.Geometry.Point3d cameraLocation, Rhino.Geometry.Vector3d cameraUp) { Rhino.Geometry.Vector3d cameraDirection = targetLocation - cameraLocation; cameraDirection.Unitize(); if (!viewport.CameraDirection.IsTiny()) { Rhino.Geometry.Vector3d cameraDirection0 = -viewport.CameraZ; Rhino.Geometry.Vector3d cameraY = viewport.CameraY; const double tiltAngle = 0; viewport.SetCameraLocation(cameraLocation); viewport.SetCameraDirection(cameraDirection); bool didSetTarget = false; didSetTarget = viewport.SetCameraUp(cameraUp); if (!didSetTarget) { didSetTarget = viewport.SetCameraUp(cameraY); cameraUp = cameraY; } if (!didSetTarget) { Rhino.Geometry.Vector3d rotationAxis = Rhino.Geometry.Vector3d.CrossProduct(cameraDirection0, cameraDirection); double sinAngle = rotationAxis.Length; double cosAngle = cameraDirection0 * cameraDirection; Rhino.Geometry.Transform rot = Rhino.Geometry.Transform.Rotation(sinAngle, cosAngle, rotationAxis, Rhino.Geometry.Point3d.Origin); cameraUp = rot * cameraY; didSetTarget = viewport.SetCameraUp(cameraUp); } if (didSetTarget) { // Apply tilt angle to new camera and target location if (Math.Abs(tiltAngle) > 1.0e-6) { Rhino.Geometry.Transform rot = Rhino.Geometry.Transform.Rotation(tiltAngle, -cameraDirection0, cameraLocation); cameraUp = rot * cameraUp; didSetTarget = viewport.SetCameraUp(cameraUp); } if (didSetTarget) { viewport.TargetPoint = targetLocation; } } } }
protected override void SolveInstance(IGH_DataAccess DA) { // get data string name = null; if (!DA.GetData(0, ref name)) { return; } Rhino.Geometry.Point3d origo = Rhino.Geometry.Point3d.Origin; if (!DA.GetData(1, ref origo)) { return; } Rhino.Geometry.Vector3d direction = Rhino.Geometry.Vector3d.XAxis; if (!DA.GetData(2, ref direction)) { // pass } double dimX = 50; if (!DA.GetData(3, ref dimX)) { // pass } double dimY = 30; if (!DA.GetData(4, ref dimY)) { // pass } if (name == null) { return; } // convert geometry FemDesign.Geometry.FdPoint3d p = origo.FromRhino(); FemDesign.Geometry.FdVector3d v = direction.FromRhino(); // return FemDesign.StructureGrid.Storey obj = new FemDesign.StructureGrid.Storey(p, v, dimX, dimY, name); DA.SetData(0, obj); }
/// <summary> /// Rotates the viewport around an axis by an angle /// </summary> public static void RotateCameraAround(this ViewportInfo viewport, Rhino.Geometry.Vector3d axis, double angle) { Rhino.Geometry.Point3d cameraLocation = viewport.CameraLocation; double targetDistance = (cameraLocation - viewport.TargetPoint) * viewport.CameraZ; Rhino.Geometry.Transform rotationTransform = Rhino.Geometry.Transform.Rotation(angle, axis, cameraLocation); Rhino.Geometry.Vector3d cameraDirection = -(rotationTransform * viewport.CameraZ); if (cameraDirection.Z >= -0.99 && cameraDirection.Z <= 0.99) // avoid gimbal "lock" { Rhino.Geometry.Point3d target = cameraLocation + targetDistance * cameraDirection; viewport.TargetPoint = target; viewport.SetCameraLocation(cameraLocation); viewport.SetCameraDirection(cameraDirection); viewport.SetCameraUp(Rhino.Geometry.Vector3d.ZAxis); } }
public bool Plane(int index, ref Rhino.Geometry.PlaneSurface plane) { Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d(); double minX = 0.0, maxX = 0.0; double minY = 0.0, maxY = 0.0; if (UnsafeNativeMethods.Rdk_CustomMeshes_Plane(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref minX, ref maxX, ref minY, ref maxY)) { plane = new Rhino.Geometry.PlaneSurface(new Rhino.Geometry.Plane(origin, xaxis, yaxis), new Rhino.Geometry.Interval(minX, maxX), new Rhino.Geometry.Interval(minY, maxY)); return(true); } return(false); }
public static Rhino.Geometry.Brep ToRhino(Wall wall) { // i know the coordinates are not right, but it's work in progress and i'm past caring. var vector = new Rhino.Geometry.Vector3d(wall.BaseLine.EndPoint.X, wall.BaseLine.EndPoint.Y, wall.BaseLine.EndPoint.Z); var origin = new Rhino.Geometry.Point3d(wall.BaseLine.StartPoint.X, wall.BaseLine.StartPoint.Y, wall.BaseLine.StartPoint.Z); var plane = new Rhino.Geometry.Plane(origin, vector); Rhino.Geometry.Interval xInterval = new Rhino.Geometry.Interval(-wall.Length / 2, wall.Length / 2); Rhino.Geometry.Interval yInterval = new Rhino.Geometry.Interval(-wall.Thickness / 2, wall.Thickness / 2); Rhino.Geometry.Interval zInterval = new Rhino.Geometry.Interval(0, wall.Height); Rhino.Geometry.Box box = new Rhino.Geometry.Box(plane, xInterval, yInterval, zInterval); var brep = box.ToBrep(); brep.Rotate(Math.PI / 2, vector, origin); return(brep); }
static public bool SaveVector(string name, string tag, Rhino.Geometry.Vector3d v) { try { StreamWriter file = new StreamWriter(name, true); string text = string.Format("{0:0.00}, {1:0.00}, {2:0.00}", v.X, v.Y, v.Z); file.WriteLine(tag + text); file.Close(); } catch (Exception e) { RhinoApp.WriteLine(e.Message); return(false); } return(true); }
public static Rhino.Commands.Result CreateSpiral(Rhino.RhinoDoc doc) { var axisStart = new Rhino.Geometry.Point3d(0, 0, 0); var axisDir = new Rhino.Geometry.Vector3d(1, 0, 0); var radiusPoint = new Rhino.Geometry.Point3d(0, 1, 0); Rhino.Geometry.NurbsCurve curve0 = GetSpirial0(); if (null != curve0) doc.Objects.AddCurve(curve0); Rhino.Geometry.NurbsCurve curve1 = GetSpirial1(); if (null != curve1) doc.Objects.AddCurve(curve1); doc.Views.Redraw(); return Rhino.Commands.Result.Success; }
public static Rhino.Commands.Result AddCylinder(Rhino.RhinoDoc doc) { Rhino.Geometry.Point3d center_point = new Rhino.Geometry.Point3d(0, 0, 0); Rhino.Geometry.Point3d height_point = new Rhino.Geometry.Point3d(0, 0, 10); Rhino.Geometry.Vector3d zaxis = height_point - center_point; Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(center_point, zaxis); const double radius = 5; Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(plane, radius); Rhino.Geometry.Cylinder cylinder = new Rhino.Geometry.Cylinder(circle, zaxis.Length); Rhino.Geometry.Brep brep = cylinder.ToBrep(true, true); if (brep != null) { doc.Objects.AddBrep(brep); doc.Views.Redraw(); } return(Rhino.Commands.Result.Success); }
static public bool OutputData(string tag, Rhino.Geometry.Vector3d v) { if (_CurrentOutput >= _OutputCount) { return(false); } _CurrentOutput++; try { string text = string.Format("{0:0.00}, {1:0.00}, {2:0.00}", v.X, v.Y, v.Z); RhinoApp.WriteLine(tag + text); } catch (Exception e) { RhinoApp.WriteLine(e.Message); return(false); } return(true); }
public override Rhino.Display.Color4f GetColor(Rhino.Geometry.Point3d _uvw, Rhino.Geometry.Vector3d duvwdx, Rhino.Geometry.Vector3d duvwdy) { //Apply the mapping transform to get tiling and offset to work Rhino.Geometry.Point3d uvw = new Rhino.Geometry.Point3d(m_mapping * _uvw); double d = uvw.X * 20; int i = (int)d; bool useColorOne = false; if (i % 2 == 0) { useColorOne = true; } else { d = uvw.Y * 20; i = (int)d; if (i % 2 == 0) { useColorOne = true; } } if (m_bSwapColors) { useColorOne = !useColorOne; } bool textureOn = useColorOne ? m_bTexture1On : m_bTexture2On; double textureAmount = useColorOne ? m_dTexture1Amount : m_dTexture2Amount; TextureEvaluator texEval = useColorOne ? textureEvaluatorOne : textureEvaluatorTwo; Rhino.Display.Color4f color = useColorOne ? m_color1 : m_color2; if (textureOn && texEval != null) { //Ensure that the original UVW is passed into the child texture evaluator color = color.BlendTo((float)textureAmount, texEval.GetColor(_uvw, duvwdx, duvwdy)); } return(new Rhino.Display.Color4f(color)); }
static public bool GetNormalVector(Rhino.Geometry.Surface surface, Rhino.Geometry.Point3d pt, ref Rhino.Geometry.Vector3d normal, double tolerance = 0.001) { double u, v; if (surface.ClosestPoint(pt, out u, out v) == false) { return(false); } Rhino.Geometry.Point3d pt2 = surface.PointAt(u, v); double distance = pt.DistanceTo(pt2); if (distance > tolerance) { return(false); } RhinoApp.WriteLine("Found the closest point on surface within {0}", distance); Rhino.Geometry.Vector3d n = surface.NormalAt(u, v); normal = n; return(true); }
/* * public Rhino.Geometry.Point3d randomPoint(Rhino.Geometry.Point3d pt, Rhino.Geometry.Vector3d n, double interval, double randomValue) * { * const int MAX_RANDOM_VALUE = 1000; * int maxValue = (int)(MAX_RANDOM_VALUE * interval); * int maxRandom = (int)((double)maxValue * (double)randomValue / 100.0); * * int n1 = _random.Next(0, maxRandom); * int n2 = _random.Next(0, maxRandom); * int n3 = _random.Next(0, maxRandom); * * // uv 간격에 따른 랜덤값 획득 * double v1 = (double)n1 / maxValue; * double v2 = (double)n2 / maxValue; * double v3 = (double)n3 / maxValue; * * Rhino.Geometry.Point3d pt2 = new Rhino.Geometry.Point3d(); * pt2.X = pt.X * (1.0 + v1); // 2.0을 나누어 uv 지점에서 노이즈 편차가 되도록 함. * pt2.Y = pt.Y * (1.0 + v2); * pt2.Z = pt.Z * (1.0 + v3); * return pt2; * } * function randomSpherePoint(x0,y0,z0,radius){ * var u = Math.random(); * var v = Math.random(); * var theta = 2 * Math.PI * u; * var phi = Math.acos(2 * v - 1); * var x = x0 + (radius * Math.sin(phi) * Math.cos(theta)); * var y = y0 + (radius * Math.sin(phi) * Math.sin(theta)); * var z = z0 + (radius * Math.cos(phi)); * return [x,y,z]; * } */ /* * public Rhino.Geometry.Point3d randomPoint(Rhino.Geometry.Surface surface, Rhino.Geometry.Point3d pt, Rhino.Geometry.Vector3d n, double interval, double randomValue) * { * double radius = interval; * double u = _random.NextDouble(); * double v = _random.NextDouble(); * double theta = 2.0 * Math.PI * u; * double phi = Math.Acos(2.0 * v - 1.0); * double x = pt.X + (radius * Math.Sin(phi) * Math.Cos(theta)); * double y = pt.Y + (radius * Math.Sin(phi) * Math.Sin(theta)); * double z = pt.Z + (radius * Math.Cos(phi)); * * Rhino.Geometry.Point3d pt2 = new Rhino.Geometry.Point3d(x, y, z); * return pt2; * } */ public Rhino.Geometry.Point3d randomPoint(Rhino.Geometry.Surface surface, double u, double v, double interval, double noise) { noise = noise / 2.0 / 100; double randomU = _random.NextDouble(); // random number from 0 to 1.0 double randomV = _random.NextDouble(); randomU = randomU * interval * noise; randomV = randomV * interval * noise; Rhino.Geometry.Point3d pt = surface.PointAt(u + randomU, v + randomV); Rhino.Geometry.Vector3d n = surface.NormalAt(u + randomU, v + randomV); double randomZ = _random.NextDouble(); // randomZ = (randomZ - 0.5) * interval * noise; randomZ = randomZ * interval * noise; n = n * randomZ; Rhino.Geometry.Point3d pt2 = pt + n; return(pt2); }
private static bool IsBrepBox(Rhino.Geometry.Brep brep) { const double zero_tolerance = 1.0e-6; // or whatever bool rc = brep.IsSolid; if( rc ) rc = brep.Faces.Count == 6; var N = new Rhino.Geometry.Vector3d[6]; for (int i = 0; rc && i < 6; i++) { Rhino.Geometry.Plane plane; rc = brep.Faces[i].TryGetPlane(out plane, zero_tolerance); if( rc ) { N[i] = plane.ZAxis; N[i].Unitize(); } } for (int i = 0; rc && i < 6; i++) { int count = 0; for (int j = 0; rc && j < 6; j++) { double dot = Math.Abs(N[i] * N[j]); if (dot <= zero_tolerance) continue; if (Math.Abs(dot - 1.0) <= zero_tolerance) count++; else rc = false; } if (rc) { if (2 != count) rc = false; } } return rc; }
public Rhino.Geometry.Transform GetTrsTransform(glTFLoader.Schema.Node node) { Rhino.Geometry.Vector3d translation = Rhino.Geometry.Vector3d.Zero; if (node.Translation != null && node.Translation.Length == 3) { translation.X = node.Translation[0]; translation.Y = node.Translation[1]; translation.Z = node.Translation[2]; } Rhino.Geometry.Quaternion rotation = Rhino.Geometry.Quaternion.Identity; if (node.Rotation != null && node.Rotation.Length == 4) { rotation.A = node.Rotation[3]; rotation.B = node.Rotation[0]; rotation.C = node.Rotation[1]; rotation.D = node.Rotation[2]; } Rhino.Geometry.Vector3d scaling = Rhino.Geometry.Vector3d.Zero; if (node.Scale != null && node.Scale.Length == 3) { scaling.X = node.Scale[0]; scaling.Y = node.Scale[1]; scaling.Z = node.Scale[2]; } Rhino.Geometry.Transform translationTransform = Rhino.Geometry.Transform.Translation(translation); rotation.GetRotation(out double angle, out Rhino.Geometry.Vector3d axis); Rhino.Geometry.Transform rotationTransform = Rhino.Geometry.Transform.Rotation(angle, axis, Rhino.Geometry.Point3d.Origin); Rhino.Geometry.Transform scalingTransform = Rhino.Geometry.Transform.Scale(Rhino.Geometry.Plane.WorldXY, scaling.X, scaling.Y, scaling.Z); return(translationTransform * rotationTransform * scalingTransform); }
public Rhino.Geometry.Vector3d ToVector3d() { Rhino.Geometry.Vector3d v = new Rhino.Geometry.Vector3d(); UnsafeNativeMethods.Rdk_Variant_Get3dVectorValue(ConstPointer(), ref v); return v; }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <returns></returns> public Rhino.Geometry.Vector3d VectorTo(Rhino.Geometry.Point3d point) { MyPlugInSdk.SdkTest(true); Rhino.Geometry.Point3d from = new Rhino.Geometry.Point3d(m_x, m_y, m_z); Rhino.Geometry.Vector3d rc = new Rhino.Geometry.Vector3d(); UnsafeNativeMethods.Expose_CreateVector(from, point, ref rc); return rc; }
public bool Box(int index, ref Rhino.Geometry.Box box) { Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d(); double minX = 0.0, maxX = 0.0; double minY = 0.0, maxY = 0.0; double minZ = 0.0, maxZ = 0.0; if (UnsafeNativeMethods.Rdk_CustomMeshes_Box(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref minX, ref maxX, ref minY, ref maxY, ref minZ, ref maxZ)) { box = new Rhino.Geometry.Box(new Rhino.Geometry.Plane(origin, xaxis, yaxis), new Rhino.Geometry.Interval(minX, maxX), new Rhino.Geometry.Interval(minY, maxY), new Rhino.Geometry.Interval(minZ, maxZ)); return true; } return false; }
/// <summary> /// <para>Magnify/Zoom the Camera in a viewport</para> /// <para>method =</para> /// <para>0 performs a "dolly" magnification by moving the /// camera along the camera direction vector so that /// the amount of the screen subtended by an object /// changes.</para> /// <para>1 performs a "zoom" magnification by adjusting the /// "lens" angle</para> /// </summary> public static bool Magnify(this ViewportInfo viewport, CGSize viewSize, double magnifcationFactor, int method, CoreGraphics.CGPoint fixedScreenPoint) { if (viewport.IsCameraLocationLocked) return false; var screenWidth = viewSize.Width; var screenHeight = viewSize.Height; if (1 > screenWidth || 1 > screenHeight) return false; // move camera toward target to magnify if (magnifcationFactor > 0) { // if the screen point is not in the viewport, then ignore it. if (!fixedScreenPoint.IsEmpty) { if (fixedScreenPoint.X <= 0 || fixedScreenPoint.X >= screenWidth - 1 || fixedScreenPoint.Y <= 0 || fixedScreenPoint.Y >= screenHeight - 1) { fixedScreenPoint.X = 0; fixedScreenPoint.Y = 0; } } double frustumLeft = viewport.FrustumLeft; double frustumRight = viewport.FrustumRight; double frustumBottom = viewport.FrustumBottom; double frustumTop = viewport.FrustumTop; double frustumNear = viewport.FrustumNear; double frustumFar = viewport.FrustumFar; double frustumWidth = viewport.FrustumWidth; double frustumHeight = viewport.FrustumHeight; double d = 0.0; // dolly camera towards target point... if (viewport.IsPerspectiveProjection && method == 0) { const double miniumumTargetDistance = 0.000001; var cameraZ = viewport.CameraZ; var cameraLocation = viewport.CameraLocation; var target = viewport.TargetPoint; double targetDistance = (cameraLocation - target) * cameraZ; if (targetDistance >= 0.0) { double delta = (1.0 - (1.0/magnifcationFactor)) * targetDistance; if (targetDistance - delta > miniumumTargetDistance) { cameraLocation = cameraLocation - (delta * cameraZ); viewport.SetCameraLocation (cameraLocation); if (!fixedScreenPoint.IsEmpty) { d = targetDistance / viewport.FrustumNear; frustumWidth *= d; frustumHeight *= d; d = (targetDistance - delta) / targetDistance; } } } } if (method == 1) { // parallel proj or "true" zoom // apply magnification to frustum d = 1.0 / magnifcationFactor; frustumLeft *= d; frustumRight *= d; frustumBottom *= d; frustumTop *= d; viewport.SetFrustum (frustumLeft, frustumRight, frustumBottom, frustumTop, frustumNear, frustumFar); } if (!fixedScreenPoint.IsEmpty && Math.Abs(d) > Double.Epsilon) { // lateral dolly to keep fixed_screen_point in same location on screen Rhino.Geometry.Vector3d scale = new Rhino.Geometry.Vector3d (1.0, 1.0, 1.0); scale.X = viewport.ViewScale.Width; scale.Y = viewport.ViewScale.Height; double fx = ((double)fixedScreenPoint.X / (double)screenWidth); double fy = ((double)fixedScreenPoint.Y / (double)screenHeight); double dx = ((0.5 - fx) * (1.0 - d) * frustumWidth) / scale.X; double dy = ((fy - 0.5) * (1.0 - d) * frustumHeight) / scale.Y; Rhino.Geometry.Vector3d dollyVector = dx * viewport.CameraX + dy * viewport.CameraY; var cameraLocation = viewport.CameraLocation; var target = viewport.TargetPoint; viewport.TargetPoint = target - dollyVector; viewport.SetCameraLocation (cameraLocation - dollyVector); } } return true; }
/// <summary> /// <para>Moves the Camera in a viewport toward a fixed point</para> /// </summary> public static bool Move(this ViewportInfo viewport, CGSize viewSize, double magnifcationFactor, CGPoint fixedScreenPoint) { if (viewport.IsCameraLocationLocked) return false; var screenWidth = viewSize.Width; var screenHeight = viewSize.Height; if (1 > screenWidth || 1 > screenHeight) return false; // move camera toward target to magnify if (magnifcationFactor > 0) { // if the screen point is not in the viewport, then ignore it. if (!fixedScreenPoint.IsEmpty) { if (fixedScreenPoint.X <= 0 || fixedScreenPoint.X >= screenWidth - 1 || fixedScreenPoint.Y <= 0 || fixedScreenPoint.Y >= screenHeight - 1) { fixedScreenPoint.X = 0; fixedScreenPoint.Y = 0; } } double frustumNear = viewport.FrustumNear; double frustumWidth = viewport.FrustumWidth; double frustumHeight = viewport.FrustumHeight; double d = 0.0; // dolly camera location and the target location... if (viewport.IsPerspectiveProjection) { const double miniumumTargetDistance = 0.000001; var cameraZ = viewport.CameraZ; var cameraLocation = viewport.CameraLocation; var target = viewport.TargetPoint; var v0 = target - cameraLocation; double targetDistance = (cameraLocation - target) * cameraZ; if (targetDistance >= 0.0) { double delta = (1.0 - (1.0/magnifcationFactor)) * targetDistance; if (targetDistance - delta > miniumumTargetDistance) { v0.Unitize (); var l = delta * v0; var newLocation = cameraLocation + l; var newTarget = target + l; viewport.SetTarget (newTarget, newLocation, Rhino.Geometry.Vector3d.ZAxis); if (!fixedScreenPoint.IsEmpty) { d = (targetDistance / 2) / frustumNear; frustumWidth *= d; frustumHeight *= d; d = ((targetDistance / 2) - delta) / (targetDistance / 2); } } } } if (!fixedScreenPoint.IsEmpty && Math.Abs(d) > Double.Epsilon) { // lateral dolly to keep fixed_screen_point in same location on screen Rhino.Geometry.Vector3d scale = new Rhino.Geometry.Vector3d (1.0, 1.0, 1.0); scale.X = viewport.ViewScale.Width; scale.Y = viewport.ViewScale.Height; double fx = ((double)fixedScreenPoint.X / (double)screenWidth); double fy = ((double)fixedScreenPoint.Y / (double)screenHeight); double dx = ((0.5 - fx) * (1.0 - d) * frustumWidth) / scale.X; double dy = ((fy - 0.5) * (1.0 - d) * frustumHeight) / scale.Y; Rhino.Geometry.Vector3d dollyVector = dx * viewport.CameraX + dy * viewport.CameraY; var cameraLocation = viewport.CameraLocation; var target = viewport.TargetPoint; viewport.TargetPoint = target - dollyVector; viewport.SetCameraLocation (cameraLocation - dollyVector); } } return true; }
/// <summary> /// Spherical linear interpolator /// </summary> public static Rhino.Geometry.Vector3d Slerp(Rhino.Geometry.Vector3d v0, Rhino.Geometry.Vector3d v1, double n) { if (n <= 0.0) return v0; if (v0 == v1 || n >= 1.0) return v1; Rhino.Geometry.Vector3d u0 = new Rhino.Geometry.Vector3d (v0); Rhino.Geometry.Vector3d u1 = new Rhino.Geometry.Vector3d (v1); u0.Unitize (); u1.Unitize (); double dot = Rhino.Geometry.Vector3d.Multiply (u0, u1); dot = ((dot) < (-1.0) ? (-1.0) : ((dot) > (1.0) ? (1.0) : (dot))); double theta = Math.Acos (dot); if (Math.Abs(theta) < Double.Epsilon) return v1; double st = Math.Sin(theta); return ( (v0 * ((Math.Sin ((1.0 - n) * theta)) / st)) + (v1 * ((Math.Sin (n * theta) / st))) ); }
public Vector3dField(string internalName, string friendlyName, Rhino.Geometry.Point3d defaultValue) : base(internalName, friendlyName) { m_defaultValue = new Rhino.Geometry.Vector3d(defaultValue); }
public bool Plane(int index, ref Rhino.Geometry.PlaneSurface plane) { Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d(); double minX = 0.0, maxX = 0.0; double minY = 0.0, maxY = 0.0; if (UnsafeNativeMethods.Rdk_CustomMeshes_Plane(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref minX, ref maxX, ref minY, ref maxY)) { plane = new Rhino.Geometry.PlaneSurface(new Rhino.Geometry.Plane(origin, xaxis, yaxis), new Rhino.Geometry.Interval(minX, maxX), new Rhino.Geometry.Interval(minY, maxY)); return true; } return false; }
/// <summary> /// Gets a world coordinate dolly vector that can be passed to DollyCamera(). /// </summary> /// <param name="screenX0">Screen coords of start point.</param> /// <param name="screenY0">Screen coords of start point.</param> /// <param name="screenX1">Screen coords of end point.</param> /// <param name="screenY1">Screen coords of end point.</param> /// <param name="projectionPlaneDistance">Distance of projection plane from camera. When in doubt, use 0.5*(frus_near+frus_far).</param> /// <returns>The world coordinate dolly vector.</returns> public Rhino.Geometry.Vector3d GetDollyCameraVector(int screenX0, int screenY0, int screenX1, int screenY1, double projectionPlaneDistance) { Rhino.Geometry.Vector3d v = new Rhino.Geometry.Vector3d(); IntPtr pConstThis = ConstPointer(); if (UnsafeNativeMethods.ON_Viewport_GetDollyCameraVector(pConstThis, screenX0, screenY0, screenX1, screenY1, projectionPlaneDistance, ref v)) v = Rhino.Geometry.Vector3d.Unset; return v; }
/// <summary> /// Gets location and vectors of this camera. /// </summary> /// <param name="location">An out parameter that will be filled with a point during the call.</param> /// <param name="cameraX">An out parameter that will be filled with the X vector during the call.</param> /// <param name="cameraY">An out parameter that will be filled with the Y vector during the call.</param> /// <param name="cameraZ">An out parameter that will be filled with the Z vector during the call.</param> /// <returns>true if current camera orientation is valid; otherwise false.</returns> public bool GetCameraFrame(out Rhino.Geometry.Point3d location, out Rhino.Geometry.Vector3d cameraX, out Rhino.Geometry.Vector3d cameraY, out Rhino.Geometry.Vector3d cameraZ) { location = new Rhino.Geometry.Point3d(0, 0, 0); cameraX = new Rhino.Geometry.Vector3d(0, 0, 0); cameraY = new Rhino.Geometry.Vector3d(0, 0, 0); cameraZ = new Rhino.Geometry.Vector3d(0, 0, 0); IntPtr pConstThis = ConstPointer(); return UnsafeNativeMethods.ON_Viewport_GetCameraFrame(pConstThis, ref location, ref cameraX, ref cameraY, ref cameraZ); }
public bool Cone(int index, ref Rhino.Geometry.Cone cone, ref Rhino.Geometry.Plane truncation) { Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d(); double height = 0.0; double radius = 0.0; Rhino.Geometry.Point3d t_origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d t_xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d t_yaxis = new Rhino.Geometry.Vector3d(); if (UnsafeNativeMethods.Rdk_CustomMeshes_Cone(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref height, ref radius, ref t_origin, ref t_xaxis, ref t_yaxis)) { cone = new Rhino.Geometry.Cone(new Rhino.Geometry.Plane(origin, xaxis, yaxis), height, radius); truncation = new Rhino.Geometry.Plane(t_origin, t_xaxis, t_yaxis); return true; } return false; }
public bool Sphere(int index, ref Rhino.Geometry.Sphere sphere) { Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(); Rhino.Geometry.Vector3d xaxis = new Rhino.Geometry.Vector3d(); Rhino.Geometry.Vector3d yaxis = new Rhino.Geometry.Vector3d(); double radius = 0.0; if (UnsafeNativeMethods.Rdk_CustomMeshes_Sphere(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref radius)) { sphere = new Rhino.Geometry.Sphere(new Rhino.Geometry.Plane(origin, xaxis, yaxis), radius); return true; } return false; }