Jump to content

Geo_face::pointinface()


Recommended Posts

I have a poly triangle. I also have another point, planar with the triangle, but outside the triangle. If I use pointInFace(), shouldn't it return 0? I'm asking because it seems to return 1 no matter where the point is.

// rough bit of example code
// I'm pretty sure I've got the right point and face setup in my real code
GEO_Face *face;
GEO_Point *point;
// code to get address of correct face and point
UT_Vector3 nml = face->computeNormal();
int inside;
inside = face->pointInFace( (const UT_Vector3)point.getPos(), &nml);

Link to comment
Share on other sites

Just guessing, but could it be that when you pass it a normal it tests for "point in plane" (else I don't see why it would need a normal unless it's used to describe a plane). Try not passing it a normal (ommit the second parameter altogether) and see what happens...

20214[/snapback]

I was creating the GEO_Face in the wrong scope. It's working fine now.

Dave

Link to comment
Share on other sites

It's used to decide which plane to project to in order to do the in/out test. You can't give it a NULL pointer or it'll likely segfault.

20332[/snapback]

Oh. OK.

I'm not sure I understand the need for it yet, but I'll definitely take your word for it. Thanks :)

The only problem I see then, is that not being able to pass it a null makes that default pretty dangerous, no?

Just in case, I'm talking about this method in GEO_Face:

//  This method determines whether the point is inside or outside the
//  polygon.  The point is assumed to be on the plane of the polygon
virtual int pointInFace(const UT_Vector3 &pos, const UT_Vector3 *myNormal = 0) const;

Link to comment
Share on other sites

...

The only problem I see then, is that not being able to pass it a null makes that default pretty dangerous, no?

That's what got me in the first place. I just started trying to fill in a value when the default wasn't working. But I agree. I think SESI should change that behaviour.

Dave

Link to comment
Share on other sites

Oh. OK.

I'm not sure I understand the need for it yet, but I'll definitely take your word for it. Thanks :)

The only problem I see then, is that not being able to pass it a null makes that default pretty dangerous, no?

Just in case, I'm talking about this method in GEO_Face:

//  This method determines whether the point is inside or outside the
//  polygon.  The point is assumed to be on the plane of the polygon
virtual int pointInFace(const UT_Vector3 &pos, const UT_Vector3 *myNormal = 0) const;

20335[/snapback]

Hmm ... that's an interesting point. :) ... So I checked it out and no one is calling it with the default argument used. Go figure.

Link to comment
Share on other sites

I'm not sure I understand the need for it yet, but I'll definitely take your word for it.

20335[/snapback]

Ah right. I probably didn't explain that properly. It projects the points to the world-aligned 2D plane which contains the largest projection of the normal vector. This reduces the 3D problem into a 2D one which then makes it easier to solve. All pretty standard stuff.

Link to comment
Share on other sites

Ah right. I probably didn't explain that properly. It projects the points to the world-aligned 2D plane which contains the largest projection of the normal vector. This reduces the 3D problem into a 2D one which then makes it easier to solve. All pretty standard stuff.

20393[/snapback]

Yup. That makes perfect sense.

For some reason, I was thinking of these faces as triangles when I wrote that post... don't ask. :whistling:

Thanks Ed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...