# Maximum PC

 It is currently Sat Apr 18, 2015 5:34 am

 All times are UTC - 8 hours

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Sines/CosinesPosted: Wed Jan 05, 2011 7:12 pm
 Northwood

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2263
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,&#952;) = cos(x) + (tan(&#952;)*x) where &#952; 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. &#952; 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.

Top

 Post subject: Re: Sines/CosinesPosted: Tue Apr 05, 2011 4:58 pm
 8086

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
x=sinwavex()
y=sinewavey()
x=((x/sqrt2)-(y/sqrt2))
y=((x/sqrt2)+(y/sqrt2))

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

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC - 8 hours

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Maximum FAQs    Forum Rules, Posting Guidelines & Announcements    The Good, The Bad & The Banned    FAQs Help/Do It Yourself    PC Building Lab    The Help Desk    PC Modding    Education & Certification Hardware    Nuts & Bolts    Portable Talk    Appraisals, Deals & Bargains (oh my!) OS/Software/Programming    Windows Parlor    Alt.OS.Abode    Games Arena    Programmers' Paradise Networking/Internet    Internet Truckstop    Network Nook In/Out    Magazine and Book Feedback    Forum & Website Feedback    Dog Pound Team Maximum PC Folding at Home    Team Maximum PC - Folding at Home - FIND CURES TO DISEASES    Team MPC - Folding Gauntlets