having an issue at getting a 3D rotate calc to work correctly.
the 2D calc works fine.
what i am doing is trying to get the red circle(3D) and yellow circle(2D) to rotate around the screen following the white path.
> each frame i am resetting the x,y location around the screen zero (top left). acts like a translate to be around zero.
> calc both 3D rotate & 2D rotate
> rotate gets increased each frame, so 'angle offset' gets bigger from reset position
> translate circles back around screen center.
> what should happen is the both circles should be in the same location around the white path. but the red 3D circle forms a figure 8...???
can't seem to work out the issue. any help is appreciated.
note: the calc works great in my 3D engine.
SetFPS 50
Do
Cls 0
;--- reset acts like translate around zero pos each frame ---
x# = 300 : y# = 0
radius = 300
;--- 3D rotate calc ---
m1# = Cos(Player_Angle2#) : m2# = -Sin(Player_Angle2#) ; x
m3# = Sin(Player_Angle2#) : m4# = Cos(Player_Angle2#) ; y
x# = x# * m1# + y# * m2#
y# = x# * m3# + y# * m4#
;--- translate back around screen center ---
CircleC 400+x#,300+y#,15,0,RGB(255,0,0) ; red circle (3D rotate)
Text 0,0,"Player Angle = " + Str$(player_angle)
;;text 0,15,"Heading Angle = " + str$(player_angle2#)
;--- standard rotate calc ---
x1# = radius * Cos(Player_Angle)
y1# = radius * Sin(Player_Angle)
;--- translate back around screen center ---
CircleC 400+x1#,300+y1#,10,1,RGB(255,255,0) ; yellow circle (standard rotate)
;--- path ---
Circle 400,300,300,0
LineC 400,300,400+x1#,300+y1#,RGB(0,100,0) ; degrees
Sync
;;flushkeys : waitkey
Inc player_angle,1
player_angle = WrapValue(player_angle,0,360) ; show angle as green line
Inc player_angle2#,1
player_angle2# = WrapAngle(player_angle2#,360)
Loop
x# is being transformed in the first expression, then used in the second expression.. So just preserve it.
[pbcode]
xr# = x# * m1# + y# * m2#
y# = x# * m3# + y# * m4#
x#=xr#
[/pbcode]
[pbcode]
SetFPS 50
Do
Cls 0
;--- reset acts like translate around zero pos each frame ---
x# = 300 : y# = 0
radius = 300
;--- 3D rotate calc ---
m1# = Cos(Player_Angle2#) : m2# = -Sin(Player_Angle2#) ; x
m3# = Sin(Player_Angle2#) : m4# = Cos(Player_Angle2#) ; y
xr# = x# * m1# + y# * m2#
y# = x# * m3# + y# * m4#
x#=xr#
;--- translate back around screen center ---
CircleC 400+x#,300+y#,15,0,RGB(255,0,0) ; red circle (3D rotate)
Text 0,0,"Player Angle = " + Str$(player_angle)
;;text 0,15,"Heading Angle = " + str$(player_angle2#)
;--- standard rotate calc ---
x1# = radius * Cos(Player_Angle)
y1# = radius * Sin(Player_Angle)
;--- translate back around screen center ---
CircleC 400+x1#,300+y1#,10,1,RGB(255,255,0) ; yellow circle (standard rotate)
;--- path ---
Circle 400,300,300,0
LineC 400,300,400+x1#,300+y1#,RGB(0,100,0) ; degrees
Sync
;;flushkeys : waitkey
Inc player_angle,1
player_angle = WrapValue(player_angle,0,360) ; show angle as green line
Inc player_angle2#,1
player_angle2# = WrapAngle(player_angle2#,360)
Loop
[/pbcode]
OMG kev, talk about a newbie mistake.
i was actually waiting up last night for the minecraft live show to start, so was up till 3am waiting for it to start. so i guess i was in tired mode.
p.s. yay i finally got 500 posts. now i go from sr member to hero member. do i wear a vip pass before i log on?