Page 1 of 1
Circular Motion [SOLVED]
Posted: Sat Feb 23, 2013 10:11 am
by Palmar
Hi everyone!
How to implement circular motion? I really don't know, how to did this on coordinate system.
Thanks in advance.
Re: Circular Motion
Posted: Sat Feb 23, 2013 10:43 am
by pakoskyfrog
Hi !
Depending on what you intend to do, you can use a polar system and convert it in rectangular system :
You can place a point thanks to 2 coordinates, either an angle and a length, or two lengths.
ie : radius and theta or x and y.
Then you make all your calculations with (radius, theta) and convert them with
x = radius * cos(theta)
y = radius * sin(theta)
with a constant radius and a angle theta increasing in time, you will have a circular (anti clockwise) motion !
But since y coords are going down, everything filps horizontally, and the motion should go clockwise.
Code: Select all
local point_r = 20 -- pxl radius
local point_t = 0 -- start angle
function love.update(dt)
point_t = point_t + dt -- one radian per second
end
function love.draw()
local ox = 150 -- center
local oy = 200
local x = point_r * math.cos(point_t) + ox
local y = point_r * math.sin(point_t) + oy
love.graphics.point(x,y)
end
Re: Circular Motion
Posted: Sat Feb 23, 2013 12:58 pm
by Palmar
pakoskyfrog wrote:Hi !
Depending on what you intend to do, you can use a polar system and convert it in rectangular system :
You can place a point thanks to 2 coordinates, either an angle and a length, or two lengths.
ie : radius and theta or x and y.
Then you make all your calculations with (radius, theta) and convert them with
x = radius * cos(theta)
y = radius * sin(theta)
with a constant radius and a angle theta increasing in time, you will have a circular (anti clockwise) motion !
But since y coords are going down, everything filps horizontally, and the motion should go clockwise.
Code: Select all
local point_r = 20 -- pxl radius
local point_t = 0 -- start angle
function love.update(dt)
point_t = point_t + dt -- one radian per second
end
function love.draw()
local ox = 150 -- center
local oy = 200
local x = point_r * math.cos(point_t) + ox
local y = point_r * math.sin(point_t) + oy
love.graphics.point(x,y)
end
Thanks, man, you helped me so much.
Re: Circular Motion [SOLVED]
Posted: Thu Nov 02, 2017 10:59 pm
by Hacdan
Hello, how can i change the point style in the version 0.10 of LOVE2D?