# Modeling trajectory of object with beams

Hey everyone,
I’m trying to model the trajectory of a ball (sphere) with beams. The issue however, is that I am unable to figure out the formula to get the correct curve for the sphere as I am not tweening the ball, instead I am just updating it in a loop (several reasons) Below is a video of the ball and the curve.

My base code for the trajectory of the ball was from this post:
Calculation of trajectories in Roblox Studio - Resources / Community Tutorials - DevForum | Roblox
ball code:

``````function BallHandler:BeginTrajectory(part, cameraCF)
local function Position(Origin, Initial, g, Time)
return Origin + Initial * Time + g * Time * Time / 2
end

local OriginPart = part
local Gravity = Vector3.new(0, -workspace.Gravity, 0)
local Velocity = 0.7
local GoTo = (OriginPart.CFrame.LookVector * 100*(Velocity*2) ) + (OriginPart.CFrame.UpVector * 51*Velocity)
local StartPosition = OriginPart.CFrame.Position
local Total = 0

self.Ball.Parent = workspace
local CurveSize0 = workspace.Start.Beam
local Attachment0 = workspace.Start.Attachment1
local Attachment1 = workspace.Start.Attachment2
--Attachment0.WorldPosition = part.Position

coroutine.wrap(function()
while self.Ball and self.Ball.PrimaryPart do
if not self.Ball.PrimaryPart then return end
local dt = game:GetService("RunService").Heartbeat:Wait()
if self.Ball.PrimaryPart then
Total += dt*(Velocity*1.65)

local g = workspace.Gravity

--Attachment1.WorldPosition = Position(StartPosition, GoTo, Gravity, Total) + Vector3.new(0,-g*dt^2/2,0)
--CurveSize0 = 9.81 * .2 * 0.7
self.Ball.PrimaryPart.CFrame = CFrame.new(Position(StartPosition, GoTo, Gravity, Total))
end

end
end)()
end
``````

As you can see in the script, I have tried various approaches to mirroring the trajectory with the curve, however none of them work. If anyone has any solutions or ideas, I’d be willing to try them.