Hi, I’m an OpenGL beginner, and I have a question for you, which is if I draw a red line on the screen, and the green rectangle represents the whole screen, how can I get the coordinates of this point in the blue circle?
Or is there any way to get the coordinates of all the points on the line?
Thank you so much. Thank you
Hey Welcome!!
Apologies for the delay.
If you treat each side of the green rect as a line you can use this function where you pass in the start and end point of the red line and the start and end point of each green line, with the last argument being the resulting intersection point:
bool ofLineSegmentIntersection(glm::vec3 & line1Start, glm::vec3 & line1End, glm::vec3 & line2Start, glm::vec3 & line2End, glm::vec3 & intersection)