Hi everyone!
How to implement circular motion? I really don't know, how to did this on coordinate system.
Thanks in advance.
Circular Motion [SOLVED]
Circular Motion [SOLVED]
Last edited by Palmar on Sat Feb 23, 2013 1:32 pm, edited 1 time in total.
- pakoskyfrog
- Citizen
- Posts: 62
- Joined: Mon Feb 04, 2013 12:54 pm
- Location: France
Re: Circular Motion
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.
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
Thanks, man, you helped me so much.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
Re: Circular Motion [SOLVED]
Hello, how can i change the point style in the version 0.10 of LOVE2D?
Who is online
Users browsing this forum: No registered users and 4 guests