Center of a quad?

Blitz3D Forums/Blitz3D Programming/Center of a quad?

kochOn(Posted 2007) [#1]
Hi!

Is anybody know how to find the exact center of a quad?

I need to write a function that create a new vertex in the middle of a quad (no diagonals) like... VertexCenter(surf, v1, v2, v3, v4).

Thanks by advance.


Jeppe Nielsen(Posted 2007) [#2]
	centerX#=(cx1+cx2+cx3+cx4)/4
	centerY#=(cy1+cy2+cy3+cy4)/4
	centerZ#=(cz1+cz2+cz3+cz4)/4

Graphics3D 800,600,32,2
cx1#=100
cy1#=100
cx2#=160
cy2#=100
cx3#=180
cy3#=140
cx4#=100
cy4#=200
Repeat
	Cls
	cx2=MouseX()
	cy2=MouseY()
	cx3=MouseX()
	cy3=MouseY()+60
	Line cx1,cy1,cx2,cy2
	Line cx2,cy2,cx3,cy3
	Line cx3,cy3,cx4,cy4
	Line cx4,cy4,cx1,cy1
	centerX#=(cx1+cx2+cx3+cx4)/4
	centerY#=(cy1+cy2+cy3+cy4)/4
	;centerZ#=(cz1+cz2+cz3+cz4)/4
	Plot centerX,centery
	Flip
Until KeyDown(1)
End



big10p(Posted 2007) [#3]
Neat. You learn something new every day, around here.


kochOn(Posted 2007) [#4]
Really great thanks mates,
didn't realise it was so easy.

Once again, this community rocks like hell...