Polygons, Shapes

P

Pete

Whats the easiest way of defining a shape
and knowing if a point is with in it?

parden the crude pseduocode...
i want something like:

Shape1 = p1,p2,p3,p4,p5,p6,p7,p8,p9,p10

pnt = x,y

if (shape1 containes(pnt)) {

}

Anyone know of something like this?

Pete
 
A

Alf P. Steinbach

Whats the easiest way of defining a shape

Try using a std::vector for the points.

and knowing if a point is with in it?

parden the crude pseduocode...
i want something like:

Shape1 = p1,p2,p3,p4,p5,p6,p7,p8,p9,p10

pnt = x,y

if (shape1 containes(pnt)) {

}

Anyone know of something like this?

What's the C++ question?

<ot>
E.g. count the number of crossing for a line through the point, or
walk the perimeter of the shape and check the direction to the point.
</ot>
 
P

Peter Ammon

Pete said:
Whats the easiest way of defining a shape
and knowing if a point is with in it?

parden the crude pseduocode...
i want something like:

Shape1 = p1,p2,p3,p4,p5,p6,p7,p8,p9,p10

pnt = x,y

if (shape1 containes(pnt)) {

}

Anyone know of something like this?

Pete

This is question 2.03 of the comp.graphics.algorithms FAQ.

http://www.exaflop.org/docs/cgafaq/ind.html

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top