PointAt (on surface which is disc)


#1

Another quick question.

I have a surface which is a disc, and am adding points to that disc via the PointAt(u,v) method and have verified all my points reside inside the limits of the Interval Domain, however when I go to add points I am getting some which do not reside on the actual surface, it appears they all reside within the bounds of the control points however. I was under the impression the U,V coordinates were always on the surface.

A disc is the only occurence of this I can find, have tried spheres, cylinders, curved surfaces, etc. Any ideas?
Thanks in advance for your time and assistance!
-Chris Slaughter


(Dale Fugier) #2

Although your 2-D points might fall inside of the domain of the surface, they might fall within the inactive region of a trimmed Brep face. You can test for this by using Rhino.Geometry.BrepFace.IsPointOnFace().


#3

That would be my go to, except I’m populating the surface with a specific number of points, any way to insure all points fall within the trimmed surface prior to testing if they are on?


(Menno Deij - van Rijswijk) #4

Well, for the specific situation where the surface is a disc, you could extract the circular boundary curve from the BREP, get the radius and determine the transformation matrix to put its center at the origin an its normal parallel to the Z-axis.
Then, you can test (transformed) points to fall within the circle radius in the XY-plane, or use the circle information to put points only within the circle.

Brep disc;
Curve[] nakedEdges = disc.DuplicateNakedEdges(true, false);
if (nakedEdges.Length == 1)
{
    Curve crv = nakedEdges[0];
    Circle c;
    if (crv.TryGetCircle(out c))
    {
        Transform toWorldXY = Transform.PlaneToPlane(c.Plane, Plane.WorldXY);
        Transform toCircle = Transform.PlaneToPlane(Plane.WorldXY, c.Plane);
        Point onDisc; // determined elsewhere
        Point onCircle = onDisc;
        onCircle.Transform(toWorldXY);
        if (Math.Sqrt(onCircle.X*onCircle.X + onCircle.Y*onCircle.Y) < c.Radius)
        {
            // point is inside the disc radius. 
        }
    }
}

#5

Thanks Menno!