Hi all,
I’m trying to use the Triangle3d structure but it seems to be non-existent in Rhino.Geometry. Is it deprecated? I’m using Rhino 6 btw.
The reason I want to use the struct is because I need to calculate the incircles of triangular faces in a mesh for determining aspect ratios, and I think that the Circumcircle property is that, but I might be wrong.
So any alternative to Triangle3d to calculate the incircle or aspect ratios is also welcome.
Thanks in advance,
Eduardo
triangle ratio.gh (10.5 KB)
For out circle we can use rhino circle class, for incircle radius > Incircle and excircles of a triangle - Wikipedia
public double TriangleRatio(Rhino.Geometry.Point3d A, Rhino.Geometry.Point3d B, Rhino.Geometry.Point3d C){
Rhino.Geometry.Circle cir;
List < Rhino.Geometry.Point3d > pts = new List<Rhino.Geometry.Point3d>{A, B, C};
Rhino.Geometry.Circle.TryFitCircleToPoints(pts, out cir);
double R = cir.Radius;
double a = A.DistanceTo(B);
double b = B.DistanceTo(C);
double c = C.DistanceTo(A);
double s = (a + b + c) / 2;
double r = Math.Sqrt((((s - a) * (s - b) * (s - c)) / s));
return (2 * r) / R;
}
2 Likes
There’s also
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Circle__ctor_3.htm
for circle through 3 points
1 Like
Thanks everyone for such quick feedback!
I ended up using a formula for aspect ratio
AR = a * b * c / ((b + c - a) * (c + a - b) * (a + b - c))
that I found here (see bottom) (c++ - Aspect ratio of a triangle of a meshed surface - Stack Overflow) and seems to be doing the job.
But I’ll definitely revert to your suggestions in case it fails down the line.
Thanks again, Eduardo
1 Like