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

Click For Summary
SUMMARY

The discussion focuses on implementing an algorithm to calculate the angle between two lines originating from the origin to points A(x1,y1) and B(x2,y2) in the Cartesian plane. The angle can be computed using the atan2(y, x) function, which accurately accounts for the signs of the coordinates. Additionally, the discussion addresses whether a third point C(x3,y3) lies on the line defined by points A and B, which can be determined by comparing the angles of the lines formed by A to B and A to C. The problem emphasizes the need for clarity in defining the algorithm and its requirements.

PREREQUISITES
  • Understanding of 2D Cartesian coordinates
  • Familiarity with trigonometric functions, particularly atan2
  • Basic knowledge of linear equations and geometry
  • Experience with algorithm implementation in programming languages
NEXT STEPS
  • Research the atan2 function in programming languages such as Python or C++
  • Study the concept of line equations in 2D geometry
  • Explore algorithms for point-line relationship determination
  • Implement a sample program to calculate angles between lines using given coordinates
USEFUL FOR

Students in mathematics or computer science, software developers implementing geometric algorithms, and anyone interested in computational geometry and trigonometry.

sHatDowN
Messages
52
Reaction score
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
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

##\ ##
 
It's my idea :
arctan(y1/y2)
It's math idea but i don't know how to implement with algorithm
 
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.
 
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:
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.
 
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 ...
 
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.
 

Similar threads

Replies
17
Views
3K
Replies
8
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
24
Views
3K
Replies
11
Views
10K