Quantcast
Channel: Cemetech
Viewing all articles
Browse latest Browse all 75370

Cemetech Labs :: RE: Google Earth -> LDraw/Minecraft ("Voxel" Decomp

$
0
0
Author: KermMartian
Posted: 09 Apr 2013 11:16:14 pm (GMT -5)

Tri is a matrix of row vectors defining a triangle. [x, y, z] are cartesian coordinates missing one of the coordinates. The desired output is [l1, l2, l3, x, y, z], where x, y, and z are all filled, and l1, l2, and l3 are the barycentric lambda coordinates.

Sample success matrix:

Code:
[[  84.68746953   59.83120068  155.70715938]
 [  82.88576245   60.64850894  152.60306357]
 [  83.41658276   58.7063019   152.60306357]]


Sample failure matrix:

Code:
[[ 49.42879067  88.10337266  56.30088594]
 [ 57.97150024  83.39647856  56.89353193]
 [ 49.42879067  88.10337266  56.89353193]]


Notice that [0,0] = [2,0] and [0,1] = [2,1] (and because the z-axis span is the smallest, z will be the missing coordinate). This will make (tri[1,b]-tri[2,b])*(tri[0,a]-tri[2,a]) + (tri[2,a]-tri[1,a])*(tri[0,b]-tri[2,b]) of course be zero. And that will be true even if the triangle points get shuffled. What to do.

Edit: Unless I shuffle rows 1 and 2 in this case, I believe... That would give:

Code:
[[ 49.42879067  88.10337266  56.30088594]
 [ 49.42879067  88.10337266  56.89353193]
 [ 57.97150024  83.39647856  56.89353193]
]
For which we get the det = (nonzero)*(nonzero) + (nonzero)*(nonzero). And I guess I can then just reshuffle the lambdas at the end.

Edit #2: Nope, although that makes the terms nonzero, it also makes the sum cancel out to zero. I should have expected it wasn't that easy.
_________________




Viewing all articles
Browse latest Browse all 75370

Trending Articles