What is the mechanism of using 4 doubles to construct a plane in GH C#?

Screenshot 2024-01-02 123820

If we take a look at the documentation, it states that a plane gets constructed from the mathematical equation Ax+By+Cz+D=0.

1 Like

BTW: Given the opportunity:

triad = triad.Where(x => x.IsValid).ToList();
    if(!triad.Any() || triad.Count != 3)return;

    Grasshopper.CentralSettings.PreviewPlaneRadius = size;

    PlaneEquation(triad[0].X, triad[0].Y, triad[0].Z, triad[1].X, triad[1].Y, triad[1].Z, triad[2].X, triad[2].Y, triad[2].Z, decimals);
    Print("E: {0}", equation);

    Point3d cent = (triad[0] + triad[1] + triad[2]) / 3;
    plane.Translate(cent - plane.Origin);

    planeAtCent = plane;
public string equation;

  public double a,b,c,d;
  public Plane plane;

  public void PlaneEquation(
    double x1, double y1, double z1,
    double x2, double y2, double z2,
  double x3, double y3, double z3, int dec){

    double a1 = x2 - x1;  double b1 = y2 - y1; double c1 = z2 - z1;
    double a2 = x3 - x1;  double b2 = y3 - y1; double c2 = z3 - z1;

    a = Math.Round(b1 * c2 - b2 * c1, dec);
    b = Math.Round(a2 * c1 - a1 * c2, dec);
    c = Math.Round(a1 * b2 - b1 * a2, dec);
    d = Math.Round((-a * x1 - b * y1 - c * z1), dec);

    equation = string.Format("x*{0} + y*{1} + z*{2} + {3} = 0", a, b, c, d);

    plane = new Plane(a, b, c, b);
  }

Plane_EquationFrom3Pts_V1.gh (6.7 KB)

1 Like

Thanks

Thanks.