Jump to content

View more

Image of the Day

「筋肉兄貴のスーパーラン!」
兄貴に立ちはだかるダンボール・・・(´・ω・`)
ムズい・・激ムズって感じにそろそろ変わってきます。
(o・ω・o)
 #indiedev  #indiegame #screenshotsaturday https://t.co/xKIzRQMdHm
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

ray-plane collision

2: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 sheep19   Members   

494
Like
0Likes
Like

Posted 20 December 2012 - 01:56 AM

Hi, I want to make my raytracer able to trace triangles, not only spheres as it currently does.

So I must first check if the ray hits the plane.

Leaving aside the triangle for now,
I have:

Vector3 a = {0, 0, 0}; // a point of the plane
Vector3 n = {0, 1, 0}; // the plane's normal
n.normalize();

Vector3 e = {0, -1, 0}; // the starting point of the ray
Vector3 d = {0, 1.0f, 0}; // the ray's direction
d.normalize();

float t = (dot(a, n) - dot(e, n)) / dot(d, n);

So, the collision point would be e + t * d.
Also, if dot(d, n) = 0, the ray and the plane are parallel.

Is that correct?

#2 DDoS   Members   

312
Like
2Likes
Like

Posted 20 December 2012 - 02:59 AM

yes this is correct, since dot product is distributive you can write t = dot(a-e.n) / dot(d,n)

ddos

edit: http://en.wikipedia.org/wiki/Line-plane_intersection -> Algebraic form

Edited by DDoS, 20 December 2012 - 03:01 AM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.