Maximum PC

It is currently Wed Jul 23, 2014 9:24 pm

All times are UTC - 8 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Sines/Cosines
PostPosted: Wed Jan 05, 2011 7:12 pm 
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Note: This isn't mine, but he poses a very interesting, and (therefore?) good question:

The characters are botched because maxpc doesn't support them, so here's the link:

http://www.modacity.net/forums/showthre ... post568054

Donut wrote:
so iv been playing super metroid lately, and as some of you know, there is a weapon called the wave beam in that game. the graphic for it is basically a cosine wave (technically its a sine wave in super metroid, but whatever). it got me thinking about the math behind graphing cosines at an angle for 360 degree wave beam firing. i know how to get the cosine curve straight up or straight forward, but not at an angle.

this is f(x) = cos(x). this is more or less what the wave beam looks like shooting straight forward.

this is as close to what i have gotten. basically, i just added a linear function to the cosine function where the slope of the linear function is an angle of my choosing
f(x,θ) = cos(x) + (tan(θ)*x) where θ is the angle i want the curve at
this is both ugly, and not what i want. the green line is the linear function i added

this is what im looking for. i just rotated the first image 45 degrees in gimp. θ is the angle the wave is tilted

what i want to know is the mathematical function that generates a cosine wave that looks like the third image. i want to implement this into a little sprite game im working on, but i dont know the math to put it at an angle. iv toyed with the idea of using f(x) = cos(x) and just tilting the result, but i dont really know how to program that either, but what im mainly looking for is the math behind a tilted cosine graph.

before anybody lmgtfy's me, i asked google, and google didnt know. i asked one of my teachers, and he didnt know, so HE asked google, and google still didnt know.

 Post subject: Re: Sines/Cosines
PostPosted: Tue Apr 05, 2011 4:58 pm 

Joined: Tue Feb 03, 2009 3:14 pm
Posts: 4
Rotation of 45 degrees ccw is
(x,y) → ((x/sqrt2)-(y/sqrt2)),((x/sqrt2)+(y/sqrt2))

I'm not sure what language you are programming in, so a bit of pseudocode

int x, y

not sure if this is the best solution, but it should work
at least it did in wolfram alpha
http://www.wolframalpha.com/input/?i=Ro ... Pi%2F4%2C+{0%2C+0}%5D%5B{x%2C+sin%28x%29}%5D

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours

Who is online

Users browsing this forum: No registered users and 1 guest

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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group