Wed, 10/10/2018 - 02:21
Hi,
I was trying to obtain the UV coordinate of the nearest point (in the sense of orthogonal projection) on a surface for a given point. I tried a simple case with a point near a plane using GeomAPI_ProjectPointOnSurf. The NearestPoint function gives the correct result, but the UV seems wrong (and so is the point computed by UV). The UV coordinates are obtained by calling LowerDistanceParameters.
I created a nominalistic example in the attachment that reproduces this error. The plane has x-axis (0,-1,0), y-axis (0,0,1), z-axis (-1, 0, 0), location (-63.5, 4.30893, 0). When I tried to project a point (-64.5, 2.88691, -3.00001) onto the plane, the UV I got is (1.42202, -66.5). The U coordinate looks correct, but V coordinate is clearly off by a far margin. The same issue appears when I tried ShapeAnalysis_Surface. Perhaps I'm misunderstanding something, but it feels the projection shouldn't fail in such a simple case.
Thanks,
Michael
Wed, 10/10/2018 - 10:47
Dear Michael,
We have performed the simple test with your data and didn't find any issue. You can see our test result below.
To exchange information about general context and needs of your projects and our services please communicate us via Contact Form.
Best Regards,
Forum supervisor
Handle(Geom_Surface) surface = new Geom_Plane(gp_Pln(ax3));
gp_Pnt p(-64.5, 2.88691, -3.00001);
GeomAPI_ProjectPointOnSurf proj(p, surface, -100, 100, -100, 100, 1e-7);
double u, v;
proj.LowerDistanceParameters(u, v);
gp_Pnt p_surf = surface->Value(u, v);
gp_Pnt p_near = proj.NearestPoint();
printf("p:(%f, %f, %f),\np_near:(%f, %f, %f),\nuv: (%f, %f),\ndist: %f,\np_surf:(%f, %f, %f)\n", p.X(), p.Y(), p.Z(), p_near.X(), p_near.Y(), p_near.Z(), u, v, proj.LowerDistance(), p_surf.X(), p_surf.Y(), p_surf.Z());
Output:
p:(-64.500000, 2.886910, -3.000010),
p_near:(-63.500000, 2.886910, -3.000010),
uv: (1.422020, -3.000010),
dist: 1.000000,
p_surf:(-63.500000, 2.886910, -3.000010)
Wed, 10/10/2018 - 20:51
Thanks for the reply! Which OS are you running the test on? I tried this program on another Mac OS and the UV coordinate I got is still (1.42202, -66.5), which has the wrong V coordinate.
Thu, 10/11/2018 - 12:55
Dear Michael,
The next Draw script of OCCT 7.3.0 works properly on macOS 10.13 High Sierra
pload ALL
plane pl -63.5 4.30893 0 -1 4.35e-15 0 -4.35e-15 -1 0
proj pl -64.5 2.88691 -3.00001
#ext_1 Parameters: 1.4220200000000047 -3.0000100000000001
Best Regards,
Forum supervisor