[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 465
  • Last Modified:

Does a point lie on the triangle?

It is given that there are four points where three points are used to form a traingle.How can I know the forth point whether it lies on the triangle(not inside or outside the triangle)?Can someone help me with this little problem?Thank you!
0
Cervan
Asked:
Cervan
  • 5
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
well, this is actually a basically math (geometry) problem.
once, you know the solution on math level, just translate it to the programming language you use.
btw: which programming language DO you use?

so, 1 point, either yes or no if it is on one of the 3 lines?
divide an conquer: you have to check, for the 3 lines between the 3 possible pairs of 2 points each time, if the point is on that line.

say, the 2 points are A and B, and the point to check is C
to know if a point is on a segment, 2 checks:
check 1: what is the Angle between AB and AC? if  0 -> then C is on the half-segment [AB)
check 2: what is the distance AB compared to the distance A? if 0 <= AC <= AB -> then C is closer to A than B

if both checks are true, then C is on the segment AB, hence on the line between A and B

0
 
ozoCommented:
0
 
CervanAuthor Commented:
actually I can find whether the point lies inside or outside the triangle,but I cannot test the forth point if it lies on the boundary of the triangle.(I am using C program)Also,I am not given the angle.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ozoCommented:
the point is on the triangle if it is on one of the line segments.
using the point in polygon test mentioned above, instead of a sign change, you would get 0
0
 
ozoCommented:
To test if a point lies exactly on a line
http://mathworld.wolfram.com/Collinear.html
To lie on a line segment it would also have to be between the end points.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now