开发者

Built in raytracing?

开发者 https://www.devze.com 2022-12-28 02:09 出处:网络
Relating to this question i was wondering if .NET has any libs (or a function) i can use to 开发者_开发知识库detect if one point collides with another.

Relating to this question i was wondering if .NET has any libs (or a function) i can use to 开发者_开发知识库detect if one point collides with another.

I am not sure what angles i should use but is there some function like this

func(point src, rect target, angle, distanceOfVision, listPointOrRectOfWalls)

Pretty unlikely but i dont know a formula or how to start. Its a quick and dirty prototype. I am thinking of writing the func but dropping angle making line of sight a rectangle and check if any wall points are between src and target.


I would solve the problem as such:

  1. Three points of the rectangle define the plane that the rectangle lies in.
  2. Instead of representing the line as a point and an angle, represent it as a point and a vector: source_point + direction_vector * t. If you set t = 1 you have two points defining your line.
  3. Compute the intersection of the line with the plane: http://en.wikipedia.org/wiki/Line-plane_intersection
  4. Check if the intersection point is contained within the rectangle.
0

精彩评论

暂无评论...
验证码 换一张
取 消