Algorithm problem involving 3 points and 3 lines in the x,y plane

If they differ by a multiple of ##\pi##, then C is not on the line through A and B.So you can use the atan2() function I mentioned in a previous post to determine the angle from the origin to each of the lines. You don't even have to compute the angles if all you're interested in is whether or not the line from A to C is the same as the line from A to B. Just compare the slopes of the lines.
  • #1
sHatDowN
52
7
Poster has been reminded (again) to show their work on schoolwork problems
Homework Statement
ArcTan Algorithm
Relevant Equations
Need to know how to implement arctan in algorithm
1- Coordinates of two points are given in x and y plane.
A(x1,y1), B(x2,y2)
Calculate the angle between the two lines passing through each of these points with the origin of linear coordinates.
2- If a line passes between the two points A and B above, does point C lie on this line?
C(x3,y3)

how to implement this algorithm?
 
Physics news on Phys.org
  • #2
sHatDowN said:
Homework Statement:Algorithm
Relevant Equations: Algorithm

how to implement this algorithm?
Make a sketch

And find the exact problem statement. Not just the word algorithm

##\ ##
 
  • Like
Likes berkeman
  • #3
It's my idea :
arctan(y1/y2)
It's math idea but i don't know how to implement with algorithm
 
  • #4
sHatDowN said:
1- Coordinates of two points are given in x and y plane.
A(x1,y1), B(x2,y2)
Calculate the angle between the two lines passing through each of these points with the origin of linear coordinates.
I think I understand what you're asking, but it's unclear. A better description would be: Calculate the angle between two lines that pass through the origin and points A and B.
sHatDowN said:
2- If a line passes between the two points A and B above, does point C lie on this line?
C(x3,y3)
Also unclear. Are the coordinates of point C given? There are an infinite number of lines that pass between points A and B. Without more information, I don't think this is solvable.
sHatDowN said:
how to implement this algorithm?
You're not implementing an algorithm -- you're attempting to solve a very vaguely defined problem.

sHatDowN said:
arctan(y1/y2)
It's math idea but i don't know how to implement with algorithm
It's not clear to me what, if anything, the arctangent has to do with the problem you're trying to solve.
 
  • #5
sHatDowN said:
It's my idea :
arctan(y1/y2)
It's math idea but i don't know how to implement with algorithm
You should become familiar with the problem of arctan(y/x) when it is not true that both y and x are positive. The problem is that arctan(y/x) = arctan(-y/-x) and arctan(y/-x) = arctan(-y/x), so arctan(y/x) is not a very simple indicator of the angle of a radial line from the origin. You would need to do a lot of additional checking about the signs of x and y.
In computer program languages this problem is greatly simplified by the function atan2( y, x). It accounts for the signs of the inputs correctly.
All angles are in radians, ##r##, where ##-\pi \lt r \le \pi##.
atan2( y1, x1) would give you the counterclockwise angle from the positive X-axis to the line (0, A). (Negative radians is going clockwise)
Similarly, atan2( y2, x2) would give you the counterclockwise angle from the positive X-axis to the line (0, B).
Can you use that to solve the problem?
 
Last edited:
  • #6
sHatDowN said:
Homework Statement:: ArcTan Algorithm
Relevant Equations:: Need to know how to implement arctan in algorithm

1- Coordinates of two points are given in x and y plane.
A(x1,y1), B(x2,y2)
Calculate the angle between the two lines passing through each of these points with the origin of linear coordinates.
2- If a line passes between the two points A and B above, does point C lie on this line?
C(x3,y3)

how to implement this algorithm?
Are you asking to show whether or not (x3,y3) lies on a line between (x1,y1) and (x2,y2)?

This is algebra.
 
  • #7
sHatDowN said:
Homework Statement:: ArcTan Algorithm
Relevant Equations:: Need to know how to implement arctan in algorithm

1- Coordinates of two points are given in x and y plane.
A(x1,y1), B(x2,y2)
Calculate the angle between the two lines passing through each of these points with the origin of linear coordinates.
2- If a line passes between the two points A and B above, does point C lie on this line?
C(x3,y3)

how to implement this algorithm?
By definition in 2 dimensional euclidean geometry, a line that passes between two points will intersect with the line defined by them. You've only given one point for the intersecting line, so ...
 
  • #8
For part 2, if the angle of the line from A to B differs from the angle of the line from A to C by a multiple of ##\pi##, then C is on the line through A and B.
 

Related to Algorithm problem involving 3 points and 3 lines in the x,y plane

What is the problem statement involving 3 points and 3 lines in the x,y plane?

The problem typically involves determining the relationships between three given points and three lines in the x,y plane. This could involve checking if the points lie on the lines, finding the intersections of the lines, or determining if the points form a triangle and how the lines interact with this triangle.

How do you determine if a point lies on a given line in the x,y plane?

To determine if a point (x, y) lies on a line given by the equation Ax + By + C = 0, you substitute the coordinates of the point into the equation. If the equation holds true (i.e., the left-hand side equals zero), then the point lies on the line. Otherwise, it does not.

What is the method to find the intersection of two lines in the x,y plane?

To find the intersection of two lines given by the equations A1x + B1y + C1 = 0 and A2x + B2y + C2 = 0, you solve the system of linear equations simultaneously. This can be done using methods such as substitution, elimination, or matrix operations (e.g., using the inverse of the coefficient matrix if it exists).

How can you check if three points form a triangle in the x,y plane?

Three points (x1, y1), (x2, y2), and (x3, y3) form a triangle if they are not collinear. To check for collinearity, you can calculate the area of the triangle formed by these points using the determinant formula: Area = 0.5 * | x1(y2 - y3) + x2(y3 - y1) + x3(y1 - y2) |. If the area is zero, the points are collinear and do not form a triangle.

What are some common applications of solving problems involving 3 points and 3 lines in the x,y plane?

Common applications include computer graphics (e.g., rendering and collision detection), geographic information systems (GIS), robotics (e.g., path planning and object recognition), and various fields of engineering and physics where spatial relationships and intersections need to be analyzed.

Back
Top