forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

rotateImage ?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
Julu Julu



Joined: 01 Nov 2005
Posts: 9
Location: Germany

PostPosted: Thu Nov 10, 2005 10:02 am    Post subject: rotateImage ? Reply with quote

Hi.

I found this function here.


Code:

function rotateImage(theImage)
   newImage = Image.createEmpty(theImage:height(), theImage:width())
   for x = 1, theImage:width() do
      for y = 1, theImage:height() do
         newImage:blit(y, x, theImage, x, y, 1, 1)
      end
   end
   return newImage
end -- rotateImage



I do not understand this function.
The picture turns always 90 degrees.
How can I turn the picture differently?

For example 50 degrees.
Back to top
View user's profile Send private message
Zenurb



Joined: 30 Sep 2005
Posts: 106
Location: United Kingdom

PostPosted: Thu Nov 10, 2005 11:24 am    Post subject: Re: rotateImage ? Reply with quote

Julu Julu wrote:
Hi.

I found this function here.


Code:

function rotateImage(theImage)
   newImage = Image.createEmpty(theImage:height(), theImage:width())
   for x = 1, theImage:width() do
      for y = 1, theImage:height() do
         newImage:blit(y, x, theImage, x, y, 1, 1)
      end
   end
   return newImage
end -- rotateImage



I do not understand this function.
The picture turns always 90 degrees.
How can I turn the picture differently?

For example 50 degrees.


You can use sin/cos functions to work out the position of each new pixel.
_________________
Proud Dvorak User
US 1.5 PSP (Original)
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Julu Julu



Joined: 01 Nov 2005
Posts: 9
Location: Germany

PostPosted: Thu Nov 10, 2005 1:01 pm    Post subject: Reply with quote

Where I must set sin/cos ?

Code:


function rotateImage(theImage)
   newImage = Image.createEmpty(theImage:height(), theImage:width())
   for x = 1, theImage:width() do
      for y = 1, theImage:height() do



         newImage:blit(   here -> ??? cos , here -> ??? sin   x, theImage, x, y, 1, 1)
      end
   end
   return newImage
end -- rotateImage
Back to top
View user's profile Send private message
Zenurb



Joined: 30 Sep 2005
Posts: 106
Location: United Kingdom

PostPosted: Thu Nov 10, 2005 1:16 pm    Post subject: Reply with quote

sin and cos are mathematic functions which describe a wave pattern, sine and cosine. cosine is at a 90 degree angle to sine.

here is some code for making something move in a circle (i don't know lua very well)


Code:
x = 130
y = 130
aimage = Image.createEmpty(100, 100)
aimage:print("lol")
while(true)
  screen.clear()
  a = a + 1
  x = x + (sin(a) * 10)
  y = y + (cos(a) * 10)
  screen:blit(x, y, aimage, 0, 0, 100, 100)
end


I think that works but probably not =)

the basic maths will work if you can fix it, to move something in a circle.

the radians value (a) goes from 0 to pi/2+pi (i think) pi=3.14152..etc and you can just divide the highest radian value by 360 then times by the angle you want to find the new position of a singular pixel.
_________________
Proud Dvorak User
US 1.5 PSP (Original)
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Julu Julu



Joined: 01 Nov 2005
Posts: 9
Location: Germany

PostPosted: Thu Nov 10, 2005 5:03 pm    Post subject: Reply with quote

Thanks :)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group