# Sine Curve

![Diminishing amplitude Sine Curve](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvAFkS9lSxDP0RviFO%2F-MOvEMn3U5MBfufO2Ci0%2Fsine1.png?alt=media\&token=52d97814-6134-4d60-aebf-8807160412c9)

```d
n = 500;
w = 10;
h = 4;
x = 0..Math.PI*2*10..#n;
y = Math.Sin(0..360*w..#n) * (h..0.1..#n);
p = Point.ByCoordinates(x,y);
c = NurbsCurve.ByPoints(p);
```

![Diminishing amplitude Sine Curve along Base Curve](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvAFkS9lSxDP0RviFO%2F-MOvFiZWYEYCq9wmwFy3%2Fsine3.png?alt=media\&token=401f78f6-534c-4d9a-aa05-a21ddaa7852d)

```d
//Base Curve
c1 = NurbsCurve.ByPoints
(Point.ByCoordinates([0,10,50],[0,10,0]));
//Number of Divisions
n = 500;
//Scale Wave Extent
w = 10;
//Scale Wave Height
h = 5;
//Points on Curve
p1 = c1.PointAtParameter(0..1..#n);
//Normal at Points
n1 = c1.NormalAtParameter(0..1..#n);
//Scale wrt Base Curve Length
s = c1.Length/(Math.PiTimes2*w);
y = Math.Sin(0..360*w..#n) * (h..0.1..#n) * s;
p2 = p1.Translate(n1,y);
//Nurbs Curve
c2 = NurbsCurve.ByPoints(p2);
```

![Diminishing amplitude Sine Curve along Base Curve with Attractor](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvAFkS9lSxDP0RviFO%2F-MOvDxI0xh9ek5fwkJj2%2FsineCurve_2020-12-18_10-59-12.png?alt=media\&token=e79cbcb5-91c0-4d9b-a2e8-e83805fc1b68)

```d
//Number of Points
ct = 200;

//Amplitude Scale
as = 2;

//Period Scale
ps = 8;

//Base Curve
bc = NurbsCurve.ByControlPoints(Point.ByCoordinates([0,10,40,50],[0,20,20,0]));
cp = bc.PointAtParameter(0..1..#ct);
cn = bc.NormalAtParameter(0..1..#ct);

//Sine Curve
ds = Math.Sin(0..360*ps..#ct)*2;
ic = Math.RemapRange(at.DistanceTo(cp),as,0);
nc = NurbsCurve.ByPoints(cp.Translate(cn,ds*Math.Pow(ic,2)));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvAFkS9lSxDP0RviFO%2F-MOvE1TrZBkykjoNyW4l%2Fsine.gif?alt=media\&token=e6957687-0663-4b25-af30-48441317740c)
