Graph of a parametric curve on an angle?

Click For Summary
SUMMARY

The discussion focuses on creating parametric curves for a two-dimensional game, specifically how to rotate a sine curve to any angle, such as 45 degrees. The original sine curve equations are defined as x = t and y = sin(t) for 0 degrees, and x = sin(t) and y = t for 90 degrees. The solution involves applying a linear transformation using rotation matrices, resulting in the equations: x = t cos(θ) - sin(t) sin(θ) and y = sin(t) cos(θ) + t sin(θ). This method allows for the manipulation of flight paths in the game to enhance visual interest.

PREREQUISITES
  • Understanding of parametric equations
  • Basic knowledge of trigonometry
  • Familiarity with linear transformations
  • Experience with game development concepts
NEXT STEPS
  • Research linear transformations in 2D graphics
  • Learn about rotation matrices and their applications
  • Explore advanced parametric curve techniques
  • Investigate game physics for flight path optimization
USEFUL FOR

This discussion is beneficial for game developers, engineering students, and anyone interested in implementing parametric curves and transformations in graphical applications.

Ownaginatious
Messages
37
Reaction score
0
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!
 
Physics news on Phys.org
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 θ:
<br /> \begin{array}{rcl}<br /> x &amp;=&amp; t \cos ( \theta ) -\sin(t) \sin( \theta ) \\<br /> y &amp;=&amp; \sin(t) \cos( \theta ) + t \sin( \theta )<br /> \end{array}<br />​
 
Last edited:
Oh wow, thanks! This is exactly what I was looking for :p
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 25 ·
Replies
25
Views
5K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K