Skip to main content
GameDev.net gamedev.net
🔒 Locked

Trig question

Started by fup Feb 19, 2003 at 3:45 PM 5 replies 350+ views
vanillacoke
vanillacoke
Is the line AB necessarily horizontal? If so, the fasatest way is probably with some similar triangles that all have one vertical leg and one horizontal leg. Otherwise, I would just use some vectory math.

Is this for ray tracing?
You know what I never noticed before?
fup
fup
I guess you could look at it as a ray tracing problem. (in 2D)

The line segment AB is defined by two 2D points A & B. p1, p2, D and C are also 2D points. Each point is defined by an x and y coordinate.

Imagine C as a light source. p1 and p2 are the end points of the shadow cast on AB by the object at point D with radius r.

Hope this clarifies the problem.




ai-junkie.com
Zipster
Zipster
You can use an isosceles triangle. Take the line between the light source and the center of the cirlce, and the base of the isosceles triangle will be perpendicular to that line, also going through the center of the circle. There are then two different ways to accomplish the projection. Given radius R, you can find those tangeant points on the cirlce by going R units in each direction.

Once you have those two points, you can create a line and project it onto AB using some projection math. I don''t have any handy, unfortunatly.

Or, once you have the two points, you can create lines between these points and the light source respectively, and simply intersect them with AB and see where they intersect.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.