issue with projectile motion on converting from 3d to 2d coordinates

I am making a soccer game where the user will have to select three parameters(angle,elevation and velocity).on selecting this three the ball will move in projectile motion as I have converted the 3d coordinates to 2d.but this is not working correctly.It is not making a projectile motion in 2d.Can anybody fix the issue or do let me know what wrong am I doing?I have been wondering since few days as what should I do?Please help me out with this problem.

[code]
local g=-9.8
local range = 0
local nearPoint = 0.9677
local timeInc = 0

–Get the initial velocity component and the initial location
function CoordinatesIn3D(thetha,phi,velocity)
–Initial location in 3D world
local initObjX = 0;
local initObjY = 0;
local initObjz = 100;

–Components Of the Ball Velocity in X,Y,Z direction
local compVelX = velocity * math.cos(thetha*math.pi/180) * math.cos(phi*math.pi/180)
local compVelY = velocity * math.sin(thetha*math.pi/180)
local compVelZ = velocity * math.cos(thetha*math.pi/180) * math.sin(phi*math.pi/180)

return initObjX,initObjY,initObjz,compVelX,compVelY,compVelZ
end

–Convert the 3D Co-ordinates into 2d Co-ordinates
function transform3DTo2D(t)
local coordX = initObjX + (compVelX * t) - (1/2)*0.5*t^2
local coordY = initObjY + (compVelY * t) + (1/2)*g*t^2
local coordZ = initObjz + (compVelZ * t)

if coordY > 0 then
range = (t + 0.4)/0.4
end
local bx = coordX/(coordZ + 100)
local by = coordY/(coordZ + 100) + (nearPoint * (coordZ + 100))

return bx,-by
end

–Move the rect
function fun()
t = (timeInc-1)*.40
local x,y = transform3DTo2D(t)

local rect = display.newRect(384 + x * 200,1000 + y,10,10)
timeInc = timeInc + 1
end

local function startGame()
initObjX,initObjY,initObjz,compVelX,compVelY,compVelZ = CoordinatesIn3D(20,40,300)
for i=1, 100 do
local t = (i-1)*.40
local x,y = transform3DTo2D(t)
end
timer.performWithDelay(20,fun,math.round(range))
end
startGame()
[/code] [import]uid: 45566 topic_id: 33150 reply_id: 333150[/import]