In screen coordinate system i.e top left corner = (0,0) and bottom right corner = (800,600), How can we find the equation of a line given ?
Also how the intersection point of this line can be calculated with the screen boundary ?
In screen coordinate system i.e top left corner = (0,0) and bottom right corner = (800,600), How can we find the equation of a line given ?
Also how the intersection point of this line can be calculated with the screen boundary ?
I think you mean {0,0} to {799,599}.
Slope of a line is rise over run.
y2-y1
-----
x2-x1
Screen boundary is unimportant.
Line {30,50} to {910,100}
dy = 100-50 = 50
dx = 910-30 = 880
slope m = 50 / 880
So to clip at right
y = mx + b or if in Europe y = mx + c
y - b = m(x3-x2)
y3 - y2 = m(x3 - x2)
(y3 - y2) / (x3 - x2) = m
and if you recall m
(y3 - y2) / (x3 - x2) = (y1 - y0) / (x1 - x0)
Simple ratios. Pick one, and plug your known values and solve the rest!
In screen coordinate system i.e top left corner = (0,0) and bottom right corner = (800,600), How can we find the equation of a line given ?
Also how the intersection point of this line can be calculated with the screen boundary ?
Do you actually put image using the pixel coordinates. Or do you(or your API) transform it into world coordinates?
@wildgoose thanks
@firstPerson yes, image is put using pixel coordinates
Actually, I have only coordinates of the point on the screen and it's direction in terms of angle from north.
Now id I have to calculate the intersection point on the map border if the point continues to move in the given direction, then what would be the most efficient way ?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.