Is this a floating point error, or a bug?

Blitz3D Forums/Blitz3D Programming/Is this a floating point error, or a bug?

Ross C(Posted 2009) [#1]
Hey guys. I was working on my editor, and i've come to a part where i want to assess whether my working plane is above the camera's middle, so i can flip it so it can be seen from below as well, and be picked. (I believe disable backface cull, does not do anything to collisions, so my pick would go right through it.)

So i though, the best way, would be to point the plane at the camera. If the x rotation came back between a certain range, i could get the direction and rotate the plane by 180. Anyways, i noticed if i record the current rotations, and rotate the entity back to them, the entity starts to spin, but only on the Y axis...??? Is this a bug?

Arrow keys Up and Down to move the plane. It should spin slightly.

Graphics3D 800,600
SetBuffer BackBuffer()

Global camera = CreateCamera()
PositionEntity camera,0,50,0

CameraFogMode camera,1
CameraFogRange camera,100,300

Global plane = CreatePlane()
EntityColor plane,255,255,100


Global plane_texture = CreateTexture(64,64)
SetBuffer TextureBuffer(plane_texture)
Color 10,10,10
Rect 0,0,64,64
Color 80,80,80
Rect 1,1,62,62

SetBuffer BackBuffer()
ScaleTexture plane_texture,6,6
EntityTexture plane,plane_texture

Color 255,255,255

While Not KeyHit(1)


	If KeyDown(200) Then
		MoveEntity plane,0,0.1,0
	End If
	If KeyDown(208) Then
		MoveEntity plane,0,-0.1,0
	End If
	
	rot_x# = EntityX(plane,True)
	rot_y# = EntityY(plane,True)
	rot_z# = EntityZ(plane,True)
	RotateEntity plane,rot_x,rot_y,rot_z
	
	UpdateWorld
	RenderWorld
	
	Text 0,0,"plane y = "+rot_y
	Flip
Wend
End



Ross C(Posted 2009) [#2]
The questions i have about the above are:

Why does it only spin on the Y axis? Why does NOT spin when i don't press a key? something weird.....

[EDIT] - I'm using v 1.98


Ross C(Posted 2009) [#3]
Ignore. Jesus. I've been awake too long. Obviously reading the entityx() and rotating to that value will cause problems... I've left it up for your amusement. Laugh away!


Guy Fawkes(Posted 2009) [#4]
HA!


Warner(Posted 2009) [#5]
But if you want to determine if the plane is above the camera, you could maybe use TFormPoint?
TFormPoint 0, 0, 0, plane, camera
if TFormedY() > 0 then 'plane is above camera



Ross C(Posted 2009) [#6]
Ah, that's better thanks. Even a simple height comparison i suppose. I have been awake too long... thanks again Warner.


_PJ_(Posted 2009) [#7]
I've been sat ehre for hours staring at code wondering why my debug thing was reporting just "0" when it should have given me a message......

It was seriously about an hour and half when I finally saw the mistake:

a tiny % instead of a $ on a function parameter. >.<


Guy Fawkes(Posted 2009) [#8]
dont u just LOVE coding? :P

XD


_PJ_(Posted 2009) [#9]
mmm Coding, Coffee and CHRIST I'm tired! the three C's :D


Adam Novagen(Posted 2009) [#10]
mmm Coding, Coffee and CHRIST I'm tired! the three C's :D

Don't you mean the four C's?? You know, Coding, Coffee, CHRIST I'm tired, and Cute kitten arguments. :D


Guy Fawkes(Posted 2009) [#11]
Ross. Look. Im sorry. I was upset the other day ok? My dad is having nose surgery, and I just.... I'm upset ok?

Forgive me..