_TITLE "STx How about a 3D embedded triangle?"
' I am translating Ashish idea to 3D
'given 3d tri
'(1,1,0)
'(1,0,1)
'(0,1,1)
tri(0).x = 1: tri(0).y = 1: tri(0).z = 0
tri(1).x = 1: tri(1).y = 0: tri(1).z = 1
tri(2).x = 0: tri(2).y = 1: tri(2).z = 1
'given test cases 6 points in 3d tri or not? 2 are made up the remaider are in which is which?
'(.66,.66,.66)
'(.46,.66,.86)
'(.83,.89,.26)
'(.55,.55,.55)
'(.75,.79,.46)
'(.79,.89,.66)
test(0).x = .66: test(0).y = .66: test(0).z = .66 'on/in
test(1).x = .46: test(1).y = .66: test(1).z = .86
test(2).x = .83: test(2).y = .89: test(2).z = .26
test(3).x = .55: test(3).y = .55: test(3).z = .55 '
test(4).x = .75: test(4).y = .79: test(4).z = .46
test(5).x = .79: test(5).y = .89: test(5).z = .66 '
triArea = HeroArea(tri(0), tri(1), tri(2))
PRINT "Main Triangle Area "; triArea
tArea1 = HeroArea(tri(0), tri(1), test(i))
'PRINT tArea1,
tArea2 = HeroArea(tri(1), tri(2), test(i))
'PRINT tArea2,
tArea3 = HeroArea(tri(2), tri(0), test(i))
'PRINT tArea3,
sum = tArea1 + tArea2 + tArea3
PRINT "Sum of sub tri"; sum;
" differance to Main"; sum
- triArea
PRINT "Test point"; i;
" is on/in the triangle." PRINT "Test point"; i;
" is NOT on/in the triangle."
a = dist3D(p1, p2)
b = dist3D(p2, p3)
c = dist3D(p3, p1)
s = (a + b + c) / 2
HeroArea
= SQR(s
* (s
- a
) * (s
- b
) * (s
- c
))
dist3D
= SQR((p1.x
- p2.x
) ^ 2 + (p1.y
- p2.y
) ^ 2 + (p1.z
- p2.z
) ^ 2)