I am trying to draw a koch curve (line) with basic trigonometric conversions.

I couldn't figure out what is the correct angle for newly generated peak point.

Here is my logic:
[![Points](https://i.stack.imgur.com/NWOwj.png)](https://i.stack.imgur.com/NWOwj.png)

Given the start point of the line, angle of the line and the length for every segment, create this scheme.

After creating the schemem, treat every sub-lines starting point as new koch curves and repeat the steps.

I suspect the problem is at point 'pt' angle value.

```
/* Angle for turning downwards after the peak point */
float angle = 2*PI - PI/6;

void koch(Point2D start, float alpha, int d, int noi) {

  Point2D p1 = new Point2D(start.x + d*cos(alpha), start.y + d*sin(alpha));
  Point2D pt = new Point2D(start.x + d*sqrt(3)*cos(alpha+PI/6), start.y + d*sqrt(3)*sin(alpha+PI/6));
  Point2D p2 = new Point2D(start.x + 2*d*cos(alpha), start.y + 2*d*sin(alpha));
  Point2D p3 = new Point2D(start.x + 3*d*cos(alpha), start.y + 3*d*sin(alpha));

  line(start.x, start.y, p1.x, p1.y);
  line(p1.x, p1.y, pt.x, pt.y);
  line(pt.x, pt.y, p2.x, p2.y);            
  line(p2.x, p2.y, p3.x, p3.y);

  if(noi != 0) {
    koch(start, alpha, d/3, noi-1);

    koch(p1, alpha + PI/3, d/3, noi-1);

    koch(pt, angle, d/3, noi-1);         //Problem is here i suspect

    koch(p2, alpha, d/3, noi-1);

  } 

  return;

}

```

Calling this function with alpha being PI/6 and noi is 2 i get:[![This](https://i.stack.imgur.com/s6Zoq.png)](https://i.stack.imgur.com/s6Zoq.png)

I want to get something like: [![This](https://i.stack.imgur.com/cBSlU.png)](https://i.stack.imgur.com/cBSlU.png)