Fereshteh Shahmiri

PhD in Computer Science - School of Interactive Computing - Georgia Institute of Technology

 

Technology Square Research Building
85 Fifth Street NW
Atlanta, GA 30308

© 2017 by Fereshteh Shahmiri. All rights reserved.

Rhino Script : C# Coding in Grasshopper

Rhino Script : C# Coding in Grasshopper

  public class circumCircle {
    Point3d p1,p2,p3,center;
    double r;
    public circumCircle(Point3d p1, Point3d p2, Point3d p3){
      this.p1 = p1;
      this.p2 = p2;
      this.p3 = p3;

    public Line createBisector(Point3d ptStart, Point3d ptEnd) {
      Point3d newPtEnd = new Point3d();

      Point3d newPtStart = (ptStart + ptEnd ) / 2;
      newPtEnd.X = newPtStart.X - 10 * (ptEnd.Y - ptStart.Y);
      newPtEnd.Y = newPtStart.Y + 10 * (ptEnd.X - ptStart.X);
      newPtStart.X = newPtEnd.X + 20 * (ptEnd.Y - ptStart.Y);
      newPtStart.Y = newPtEnd.Y - 20 * (ptEnd.X - ptStart.X);


      return new Line(newPtStart, newPtEnd);
    }

    public double intersect2Lines(Line line01, Line line02) {
      double D; //
Denominator
      double E; // Enumerator

      //line01
      double line01startX = line01.From.X;
      double line01endX = line01.To.X;
      double line01startY = line01.From.Y;
      double line01endY = line01.To.Y;
  
    //line02
      double line02startX = line02.From.X;
      double line02endX = line02.To.X;
      double line02startY = line02.From.Y;
      double line02endY = line02.To.Y;

      D = (line02endY - line02startY) * (line01endX - line01startX)
        - (line01endY - line01startY) * (line02endX - line02startX);

      if (D == 0) return -1.0;

      E = (line02endX - line02startX) * (line01startY - line02startY)
        - (line02endY - line02startY) * (line01startX - line02startX);

      //intersection function - parameter to locate the intersecting point with the line range
      double intersection = E / D;
      if (intersection < 0 || intersection > 1) return -1.0;

      return intersection;
    }

    public Curve createCrv(int degree, List<Point3d> vertices) {

      NurbsCurve nCurve = NurbsCurve.Create(true, degree, vertices);

      return nCurve;
    }
  }

 

PARAMETRIC SCRIPTING

 

These examples are done in

"Parametric Design" Course,

Special Thanks to Professor Ramesh Krishnamurti

Fall 2012