HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need help for a rotation in 3D.

08-12-2008, 12:29 PM#1
Na_Dann_Ma_GoGo
Hi,
I want to rotate 2 units around a point. But the way I do it at the moment does only work perfectly for the units facing radians 0.5pi, 1pi, 1.5pi, 2pi. When the facing radians get close to 0.25pi , 0.75pi , 1.25 pi , 1.75 pi the x and y values mess up. Here's what I got so far.

Collapse JASS:
if f.time <= 300 * f.max_time then    

    call SetUnitFlyHeight(f.ice, FLY_HEIGHT + DISTANCE + DISTANCE * Sin( PI_DOUBLE * f.time),0)
    call SetUnitFlyHeight(f.fire, FLY_HEIGHT + DISTANCE + DISTANCE * Sin( bj_PI +  PI_DOUBLE * f.time),0)
    
    call SetUnitX(f.ice,f.caster_x + (DISTANCE * Sin(PI_HALF + PI_DOUBLE * f.time)) * Sin(f.facing))
    call SetUnitY(f.ice,f.caster_y + (DISTANCE * Sin(PI_HALF + PI_DOUBLE * f.time)) * Cos(f.facing))
            
    call SetUnitX(f.fire,f.caster_x + (DISTANCE * Sin(bj_PI + PI_HALF+ PI_DOUBLE * f.time)) * Sin(f.facing))
    call SetUnitY(f.fire,f.caster_y + (DISTANCE * Sin(bj_PI + PI_HALF+ PI_DOUBLE * f.time)) * Cos(f.facing))

set f.time = f.time + SLIDE_PERIOD
else
08-12-2008, 01:45 PM#2
Anitarf
Collapse JASS:
local real dx
local real dy
local real dz
...
if f.time <= 300 * f.max_time then    
    set dz = DISTANCE * Sin( PI_DOUBLE * f.time)
    set dy = DISTANCE * Cos(PI_DOUBLE * f.time) //this is actually dxy, we're just saving one variable by using dy for this

    set dx = dy * Cos(f.facing) //I don't know how you want them to rotate,
    set dy = dy * Sin(f.facing) //so you might need to add bj_PI/2 to f.facing here

    call SetUnitFlyHeight(f.ice, FLY_HEIGHT + DISTANCE + dz),0)
    call SetUnitX(f.ice, f.caster_x + dx)
    call SetUnitY(f.ice, f.caster_y + dy)
            
    call SetUnitFlyHeight(f.fire, FLY_HEIGHT + DISTANCE - dz),0)
    call SetUnitX(f.fire, f.caster_x - dx)
    call SetUnitY(f.fire, f.caster_y - dy)

set f.time = f.time + SLIDE_PERIOD
else
08-12-2008, 04:36 PM#3
Na_Dann_Ma_GoGo
Thanks a lot man, works exactly how it should (when I add the bj_PI/2 at the part you commented) ;D