Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:osculatingplane [2015/09/14] (current)
Line 1: Line 1:
 +====== Curve Osculating Planes ======
 +> **Developer:​** //​[[developer:​rhinoscript|RhinoScript]]//​
 +> **Summary:​** //How to calculate osculating planes.//
 +
 +=====Question=====
 +Is it possible to calculate the osculating plane at point P on a given curve with the methods provided by RhinoScript?​
 +
 +
 +=====Answer=====
 +Yes. There are a number of methods included in [[developer:​rhinoscript|RhinoScript]] that can be used to calculate a curve'​s osculating plane, such as CurveClosestPoint,​ CurveTangent,​ CurveCurvature,​ and CurveEvaluate. In this example, we will use the CurveEvaluate function to calculate the 2nd derivative of a curve at a parameter
 +
 +<code vb>
 +Function CurveOsculatingPlane(crv,​ t)
 +  CurveOsculatingPlane = Null ' default return value
 +  If Not Rhino.IsCurveLinear(crv) Then
 +    Dim rc : rc = Rhino.CurveEvaluate(crv,​ t, 2)
 +    If IsArray(rc) Then
 +      CurveOsculatingPlane = Rhino.PlaneFromFrame(rc(0),​ rc(1), rc(2))
 +    End If
 +  End If
 +End Function
 +</​code>​
 +
 +The following is an example of how you might use this function.
 +
 +<code vb>
 + Sub TestCurveOsculatingPlane
 +   Dim segs : segs = 10
 +   Dim crv : crv = Rhino.GetObject("​Select non-linear curve",​ 4)
 +   If Not IsNull(crv) Then
 +     Dim pts : pts = Rhino.DivideCurve(crv,​ segs)
 +     If IsArray(pts) Then
 +       Dim i, t, p
 +       For i = 0 To UBound(pts)
 +         t = Rhino.CurveClosestPoint(crv,​ pts(i))
 +         p = CurveOsculatingPlane(crv,​ t)
 +         ​Rhino.AddPlaneSurface p, 1.0, 1.0
 +       Next
 +     End If
 +   End If
 + End Sub
 +</​code>​
 +
 +
 +{{tag>​Developer RhinoScript}}
  
developer/scriptsamples/osculatingplane.txt ยท Last modified: 2015/09/14 (external edit)