General Category > General Anim8or Forum

WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)

<< < (35/58) > >>

cooldude234:

--- Quote from: Thanos on February 15, 2013, 11:06:00 am ---An example in 2D: a 2D line is described by y=ax+b. a is equal to tan(t), where t is the angle of the line. A vertical line is x=c. How much is a here? There is no a here, but vertical means, t=90 deg -> a=tan90 = #inf... unless you use different system to describe the line, without a and b.
Same for 3D.

--- End quote ---
0.0 .....Ummm yea I don't get it

Thanos:
Ah never mind I just used an if-branch for the division by zero.
I found the second bug too!! And it was SUCH A DUMB BUG :-X

So, cooldude234, here is ray-triangle intersection, version 2, I think it works ok now - I'm sorry I was that slow! I had some exams to sit these days. I hope it serves you well! If you find another bug, just let me know.


EDIT 2, 23/2/2013: Nope, this didn't work too. See version 3 for an update.

cooldude234:
IT WORKS, sort of.
Everything is flipped on the z and x axis (when I draw something on the right side of the 0,0,0 worlds origin, the collision happens on the left side).
Now this is just stupid, I flipped every number I can and it either breaks, or does the exact same thing. I flipped the vertices and the collision point and it does the exact same thing ??? what the heck?

Also I don't mean to pester but can you go through and explain in the dumbed down version what your method of checking to see if it lies inside the triangle do? (by the way I'm using a different method of checking collision with the plane).

cooldude234:
Alrighty I got it to work, and I found out it doesn't work.
In other words I fixed the flipped axis issue but the checking if the collision is inside the triangle only works on 90 degree angles, on any other angle it screws up.
So now I'm right back to where I was before with all this stuff (several other methods only worked on 90 degrees, actually they may have been the same method but with just different implementations of it).
So... any thoughts?

Thanos:
Oh boy... you're right, there's still another bug. Please be patient, I'll track it down.

What coordinate system are you using? x=right, y=up, z=back (standard)? x=right, y=up, z=far (flipped - probably not)? or maybe x=right, y=far, z=up (the best imho but nobody uses it)?

What I'm using. We know that two vertices have the same direction if their inner product is positive, the opposite direction if it's negative, zero if they form a right angle. Ie. if they form a 45 deg angle, x1*x2+y1*y2+z1*z2>=0, whereas for 120 deg it's <0.
So, if we take the vectors starting at the midways and ending at the corners, a point has to be 'in front of them' to be inside the triangle.

See the pic for an example. The dot inside the triangle is in front of all the sides, so the inner product with the red vectors will be positive in all cases. Instead, the blue dot outside is in front of the left and the down sides, but the right side looks the other way, so the inner product with its red vector will be negative.

Of course all vectors have to be relative to the midway before calculation (the second bug I corrected).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version