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.
 

Similar threads

  • Precalculus Mathematics Homework Help
Replies
17
Views
1K
  • Precalculus Mathematics Homework Help
Replies
8
Views
2K
  • Precalculus Mathematics Homework Help
Replies
2
Views
928
  • Precalculus Mathematics Homework Help
Replies
6
Views
2K
  • Precalculus Mathematics Homework Help
Replies
17
Views
1K
  • Precalculus Mathematics Homework Help
Replies
2
Views
1K
  • Precalculus Mathematics Homework Help
Replies
3
Views
2K
  • Precalculus Mathematics Homework Help
Replies
20
Views
2K
  • Precalculus Mathematics Homework Help
Replies
18
Views
673
  • Precalculus Mathematics Homework Help
Replies
24
Views
2K
Back
Top