eejai42
eejai42

Reputation: 746

Finding the surface of a triangle in a cartesian cube

I have a 3 dimensional array of bit values (either 0 or 1) representing the X, Y and Z axis (in the range of 0-99) of a cartesian cube. The entire array is initialized to all 0's.

Additionally I have a triangle of points within that cube identified by the following points.

TriangleA: [
15, 22, 11,
86, 76, 67,
45, 51, 91
]

Marking those three points with a value of 1 would be easy. My question is this:

How would I mark all of the other coordinates of the surface identified by that triangle with a value of 1 as well?

Basically how would I implement the function:

public bool IsOnSurfaceOfTriangleA(x, y, z) {

   // Math goes here! :)

}

Any help/suggestions would be greatly appreciated.

Upvotes: 0

Views: 215

Answers (2)

eejai42
eejai42

Reputation: 746

I found this MatLab function that I was able to port over to C# -works great. Now I need to do this for a whole bunch of meshes all at once, so I'll post that in a separate question. Thanks for all your help!

http://www.mathworks.com/matlabcentral/fileexchange/22857-distance-between-a-point-and-a-triangle-in-3d

Upvotes: 0

Ghostli
Ghostli

Reputation: 423

I would use a loop that is using this solution. Simple determine the min and max range and run them in a double for loop(from min till max)

Upvotes: 1

Related Questions