Skip to content

Instantly share code, notes, and snippets.

@kdrnic
Created April 26, 2018 19:47
Show Gist options
  • Select an option

  • Save kdrnic/3e70efa97531eae8b5d36e60d3330aaa to your computer and use it in GitHub Desktop.

Select an option

Save kdrnic/3e70efa97531eae8b5d36e60d3330aaa to your computer and use it in GitHub Desktop.
//Basic plane equation
P . n + d = 0
//Therefore, 3 plane equations
X * n1x + Y * n1y + Z * n1z + d1 = 0
X * n2x + Y * n2y + Z * n2z + d2 = 0
X * n3x + Y * n3y + Z * n3z + d3 = 0
//Isolate X in 1st eq
Y * n1y + Z * n1z + d1 = -X * n1x
(Y * n1y + Z * n1z + d1) / n1x = -X
X = -(Y * n1y + Z * n1z + d1) / n1x
//Replace X with isolate above, on 2nd eq
(-(Y * n1y + Z * n1z + d1) / n1x) * n2x + Y * n2y + Z * n2z + d2 = 0
(-(Y * n1y * n2x) / n1x) + (-(Z * n1z + d1) / n1x) * n2x + Y * n2y + Z * n2z + d2 = 0
Y * ((-(1 * n1y * n2x) / n1x) + n2y) + (-(Z * n1z + d1) / n1x) * n2x + Z * n2z + d2 = 0
-Y * ((-(1 * n1y * n2x) / n1x) + n2y) = (-(Z * n1z + d1) / n1x) * n2x + Z * n2z + d2
Y = ((-(Z * n1z + d1) / n1x) * n2x + Z * n2z + d2) / -((-(1 * n1y * n2x) / n1x) + n2y)
//Too big, give up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment