1
votes

I am having trouble figuring this out, I have 2 points A & B, I need to draw a straight line, and then see if this line intersects with circle C

What is the best way to do this? (I am new to Postgres so details would be super appreciated), steps to do:

  • draw line from A to B
  • see if line L intersects circle C of radius R
1

1 Answers

3
votes

You can use ST_MakeLine to create a line from two points and ST_Intersects to see if it intersects with the circle.

But it is probably easier to use the <-> distance operator to see if the distance of the line from the center is less than the radius.