# How to compute barycentric coordinates in a systematic and efficient way?

As part of a ray tracer implementation, I need to compute the barycentric coordinates in a triangle in 3D in order to decide if a ray hits the triangle or not. In theory this could be done by simply solving a few linear equations. But due to the fact that the vertices of a triangle could have the same x, y or z coordinates, some of the coefficients in the equations would be 0, and this caused numerical error in my initial implementations. So, is there a systematic approach to find the barycentric coordinates in a more efficient way? Or I have no choice but to brutally check each possibility one by one?

-
This isn't the right stackexchange for this question, but it's been answered already here. gamedev.stackexchange.com/questions/23743/… – ThinkingMedia Apr 21 '13 at 17:23
@Mathew Foscarini This is the second time I got told to have posted the question to the wrong stackexchange. Frankly speaking I have no idea which one to post, but your link turns out to be very useful and solved my problem. Thanks anyway. – God_of_Thunder Apr 22 '13 at 14:59
It's not so much that it's the wrong place, but that the users of this stackexchange won't give you the best answer simply because this is outside their scope of interest. You'll find people over at gamedev far more friendly cause they share the same interest in 3D graphics and 3D math. – ThinkingMedia Apr 22 '13 at 16:32
@Mathew Foscarini I thought this place convers a wide range of computer science related topics, not just programming. Maybe I am wrong. – God_of_Thunder May 13 '13 at 22:57
Well, programmers stack exchange is not computer science stack exchange. But actually, you got a link to an answer here, so your question was not totally misplaced here ;-) – Doc Brown Jun 20 '13 at 20:32