1

I am trying to plot a parametric parabola given by x(t)=125cos(30)t and y(t)=3+125sin(30)t-16t^2

Here is my code

\begin{center}
\begin{tikzpicture}
\begin{axis}
\addplot[blue, samples=40, variable=\t, domain=0:4]
    ({125*t*cos(deg(30)))},
    {3+125*t*sin(deg(30))-16*t^2});
\end{axis}
\end{tikzpicture}
\end{center}

This is what i get:

enter image description here

And this is what I'm after enter image description here

  • Your code has an x^2 in it. Is it supposed to be t^2? – Willie Wong Jul 17 '16 at 2:28
  • I was about to freak out, but i changed it and it didnt help – Tony Mau Jul 17 '16 at 2:53
  • What did you get as an output? – Willie Wong Jul 17 '16 at 2:58
  • I just edited my original post. unfortunaly i dont know how to generate the graph without converting the whole page to a .png – Tony Mau Jul 17 '16 at 3:05
1

A few (possible) problems with your code:

  1. By issuing domain=0:4 you are telling TikZ to plot between t = 0 and t = 4. It appears from your desired output you want to plot between approximately x = 0 and x=4.
  2. By issuing deg(30) you are not plotting cosine and sine of 30 degrees; instead you are plotting cosine and sine of 30 radians. (The deg function converges from radians to degrees; TikZ's trigonometry functions assume its arguments are in degrees.)

Sanity check: cosine of 30 radians is 0.154, mulitplied by 4 times 125 gives 77.13 which matches very well with the upper bound of what you observed to be the output.


To get the plot you want, you probably want to remove the calls to deg (since I am pretty sure you don't want something bizarre like 30 radians). And you should also change your domain to something like 0:0.05 which would give upper and lower bounds for x to be approximately 0 to 5.

  • So, removing deg() totally worked; however, i had to keep the domain at 0:4 as i need t to go to 4. Thank you for the help, and just to clarify—using deg() converts the number to radian? What if i were to use a variable such as deg(x)? – Tony Mau Jul 17 '16 at 3:39
  • 1
    No: in TikZ when you type sin(x) it is expected that x is the angle in degrees. If you want to use radian values, you have to first convert the radian value r to degrees by issuing deg(r). So deg(2*pi) is equal to 360. (In other words, deg is a function that takes input a radian angle measure and outputs the equivalent degree measure.) – Willie Wong Jul 17 '16 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.