POJ1584 to determine whether a polygon is convex, and to determine the distance from a point to a straight line

Source: Internet
Author: User

To find the distance from the point to the straight line:

Double dis (point p1,point p2)
{
if (Fabs (p1.x-p2.x) <exp)//Equal
{
return Fabs (P2.X-PEGX);
}
Else
{
Double k= (P2.Y-P1.Y)/(p2.x-p1.x);
Double b=p2.y-k*p2.x;
return Fabs (k*pegx-pegy+b)/sqrt (k*k+1);//return distance
}
}
Determine whether a polygon is convex

If the hole contains any protrusions (i.e), if there exist any of interior points in the hole so, if connected by a Lin e segment, that segment would cross one or more edges of the hole) (in parentheses is an English description of the definition of a convex polygon), then the Filled-in-hole would isn't be Structurally sound enough to support the peg under normal stress as the furniture are used.

Read the edges sequentially, edges and edges are in one order (the cross product is all positive or all negative)

POJ1584 to determine whether a polygon is convex, and to determine the distance from a point to a straight line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.