Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Graph of a parametric curve on an angle?

  1. Apr 4, 2009 #1
    I'm currently making a two dimensional game on my computer and I'm having a problem that pertains to parametric curves.

    Currently I'm trying to figure out an equation for a graph on any angle (say a sin curve). The reason for this is to make the "flight paths" of the ships in the game more interesting. Right now they basically fly towards a target from any angle.

    So far, I've figured out that for a normal sin curve along the x-axis, the equation is (0 degrees):

    x = t
    y = sin(t)

    And along the y-axis is (90 degrees):

    x = sin(t)
    y = t

    Now what I'm trying to figure out is how to make the sin graph appear on any angle, say along a 45 degree angle.

    Can anyone help me figure out an equation for that? I know this is probably simple, but I'm only a first year engineering student and haven't spent much time on parametric curves :p.

    Thanks!
     
  2. jcsd
  3. Apr 4, 2009 #2

    sylas

    User Avatar
    Science Advisor

    You can do any linear transformation with its matrix. Here's a rotation.

    Let your original curve (x,y) b given as parametric equations x=f(t), y=g(t).

    To rotate by an angle θ, map (x,y) to (x.cos(θ) - y.sin(θ), y.cos(θ) + x.sin(θ)).

    The mappings in order are t --> (f(t),g(t)) --> (f(t).cos(θ) - g(t).sin(θ), g(t).cos(θ) + f(t).sin(θ)).

    Putting it together, here is your sin curve, time parameter t, rotated by angle θ:
    [tex]
    \begin{array}{rcl}
    x &=& t \cos ( \theta ) -\sin(t) \sin( \theta ) \\
    y &=& \sin(t) \cos( \theta ) + t \sin( \theta )
    \end{array}
    [/tex]​
     
    Last edited: Apr 4, 2009
  4. Apr 5, 2009 #3
    Oh wow, thanks! This is exactly what I was looking for :p
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Graph of a parametric curve on an angle?
  1. Parametric Curves (Replies: 0)

  2. Parametrizing a curve (Replies: 4)

Loading...