Curves and Surfaces

## 1 Curve and parameter

If a curve is given by the form C=C(t), the curve is called parametric curve.
C is the point at t or the (x,y,z) coordinate of the point at t. Input: Crv a Curve
Input: t the parameter

Connect a slider to "t" slot.
Our first Python script for curves is,

```import rhinoscriptsyntax as rs
a=rs.EvaluateCurve(Crv,t)
```

If min or max value of the slider is too small or too big, the obtained point may be out from the curve.   ## 2 Curve domain

In order to ristrict the point to be between two ends of the curve, you need to get the domain of the curve.

```domain=rs.CurveDomain(Crv) #Unpacking
if t<domain:
t=domain
if t<domain:
t=domain
a=rs.EvaluateCurve(Crv,t)
```

or using Unpacking, it is

```(min,max)=rs.CurveDomain(Crv) #Unpacking
if t<min:
t=min
if t>max:
t=max
a=rs.EvaluateCurve(Crv,t)
```

## 3. Another way to avoid being nervous about domain

In most cases, programmer would prefer to set min/max of the slider to 0/1.
So, let's set min of the slider to 0 and max to 1.
In order to map 0 to the min of the domain and 1 to the max if the domain,
we use
T=min+(max-min)*t
The code should be,

```import rhinoscriptsyntax as rs
(min,max)=rs.CurveDomain(Crv)
T=min+(max-min)*t
a=rs.EvaluateCurve(Crv,T)
```

rhinoscriptsyntax provides the same functionality by CurveParameter().

```import rhinoscriptsyntax as rs
#(min,max)=rs.CurveDomain(Crv)
#T=min+(max-min)*t  #next line has same functionality as this line
T=rs.CurveParameter(Crv,t)
a=rs.EvaluateCurve(Crv,T)
```

CurveParameter() is frequently used.

## 4. Closest point to a curve ```import rhinoscriptsyntax as rs

t=rs.CurveClosestPoint(Crv,P)
point=rs.EvaluateCurve(Crv,t)
a=list()
a.append(point)
a.append(line)
``` ## 5. Other important geometric properties ```import rhinoscriptsyntax as rs
t=rs.CurveClosestPoint(Crv,P)
point=rs.EvaluateCurve(Crv,t)
planeP=rs.CurvePerpFrame(Crv,t)
planeT=rs.CurveFrame(Crv,t)
V=rs.CurveTangent(Crv,t)
a=list()
a.append(point)
a.append(line)
a.append(line2)
a.append(planeP)
a.append(planeT)
``` ## 6. Distributing points along a curve ```import rhinoscriptsyntax as rs
N=20
a=list()
for i in range(N+1):
T=rs.CurveParameter(Crv,i/N)
a.append(rs.EvaluateCurve(Crv,T))
``` ## 7. Equally distributing points along a curve

Because t is just a parameter it does not divide a curve evenly.
So, if you want to divide a curve equally, you need to use CurveArcLengthPoint(). ```import rhinoscriptsyntax as rs
N=20
a=list()
L=rs.CurveLength(Crv)
for i in range(N+1):
point=rs.CurveArcLengthPoint(Crv,i/N*L)
a.append(point)
``` ## 8. Surface and parameter Let's remain min/max of the sliders to 0/1.
For surfaces, SurfaceParameter is provided to fit the uv parameter to the domain of the surface.
```import rhinoscriptsyntax as rs
(U,V)=rs.SurfaceParameter(Srf,(u,v))
point=rs.EvaluateSurface(Srf,U,V)
a=point
``` ## 9. Extracting isocurves

If you fix v coordinate and only move u coordinate, the point will draw a tragectory. This is an isocurve of u direction. ```import rhinoscriptsyntax as rs
(U,V)=rs.SurfaceParameter(Srf,(u,v))
point=rs.EvaluateSurface(Srf,U,V)
a=point
iU=rs.ExtractIsoCurve(Srf,(U,V),0)
iV=rs.ExtractIsoCurve(Srf,(U,V),1)
``` ## 10. Closest point to a surface ```import rhinoscriptsyntax as rs
a=list()
(U,V)=rs.SurfaceClosestPoint(Srf,P)
iU=rs.ExtractIsoCurve(Srf,(U,V),0)
iV=rs.ExtractIsoCurve(Srf,(U,V),1)
point=rs.EvaluateSurface(Srf,U,V)
a.append(point)
a.append(line)
``` ## 11. Local information of a surface ```import rhinoscriptsyntax as rs
a=list()
(U,V)=rs.SurfaceClosestPoint(Srf,P)
iU=rs.ExtractIsoCurve(Srf,(U,V),0)
iV=rs.ExtractIsoCurve(Srf,(U,V),1)
plane=rs.SurfaceFrame(Srf,(U,V))
normal=rs.SurfaceNormal(Srf,(U,V))
point=rs.EvaluateSurface(Srf,U,V)
a.append(point)
#a.append(line)
a.append(line2)
a.append(plane)
``` ## 12. Distributing points onto a surface ```import rhinoscriptsyntax as rs
a=list()
(U,V)=rs.SurfaceClosestPoint(Srf,P)
iU=rs.ExtractIsoCurve(Srf,(U,V),0)
iV=rs.ExtractIsoCurve(Srf,(U,V),1)
nU=10
nV=10
for i in range(nU+1):
for j in range(nV+1):
(U,V)=rs.SurfaceParameter(Srf,(i/nU,j/nV))
plane=rs.SurfaceFrame(Srf,(U,V))
normal=rs.SurfaceNormal(Srf,(U,V))
point=rs.EvaluateSurface(Srf,U,V) 