<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/function-to-simulate-simple-parabolic-shooting/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://feedproxy.google.com/~r/DataRValue/~3/bPu8R05Uuo4/function-to-simulate-parabolic-shot.html"> Data R Value</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><span><span lang="en"><span>This function simulates a parabolic shot from the origin and does not take into account the friction of the air.</span></span></span></p>
<p><span><span lang="en"><span># Script to calculate <span>the most important info</span> about the parabolic<br># shot without friction and in <b>International System of Units</b></span></span></span><br><span><span lang="en"><span><b># </b></span></span></span><span><span lang="en"><span><span lang="en"><span><span>i</span>f you want to use another system of units only change the value</span></span></span></span></span><br><span><span lang="en"><span><span lang="en"><span># of g and the <span>units in the p<span>rints<span> and legends</span></span></span></span></span>
<p># Inputs of the function are:<br># a) initial velocity vo<br># b) shot angle alfa</p>
<p># Parameter<br># <span>c</span>) gravity acceleration g = 9.81 m/s^2</p>
<p># The outputs of the function are:<br># T_1: ascending time<br># T_2: descending time<br>#   H: maximum height<br>#   Tt: total time<br>#   L: maximum horizontal range</p>
<p><b>parabolic &lt;- function(vo, alfa){<br>  <br>    g &lt;- 9.81<br> an &lt;- round((2*pi*alfa)/360,2)<br>  T_1 &lt;- round(vo*sin(an)/g,2)<br>    H &lt;- round((vo^2)*(sin(an)^2)/(2*g),2)<br>  T_2 &lt;- round(vo*sin(an)/g,2)<br>  T_t &lt;- round(2*vo*sin(an)/g,2)<br>    L &lt;- round(vo^2*sin(2*an)/g,2)<br>  <br>  print(“Ascending time”);print(paste(T_1,”s”))<br>  print(“Maximum height”);print(paste(H,”m”))<br>  print(“Descending time”);print(paste(T_2, “s”))<br>  print(“Total time”);print(paste(T_t,”s”))<br>  print(“Max. horizontal range”);print(paste(L,”m”))<br>  <br>  y &lt;- vector()<br>  p &lt;- seq(0.0, round(L), round(L)/100)<br>  <br>  for(i in 0:length(p)){<br>    y[i] &lt;- (tan(an)*p[i])-((g/((2*vo^2)*cos(an)^2))*p[i]^2)<br>   }<br>  <br>  plot(p, y, xlab=”X”, ylab=”Y”, type = “o”, col = “red”, axes=F)<br>  axis(1, at = seq(0,L,L/10),labels=seq(0,L,L/10),<br>       cex.axis=0.7)<br>  axis(2, at = seq(0,H,H/100),labels=seq(0,H,H/100),<br>       cex.axis=0.7)<br>  legend(L/4, H/3, legend = c(paste(“vo =”, vo, “m/s”),<br>                paste(“alfa =”, alfa,”degrees”),<br>                paste(“Ascending time”, paste(T_1,”s”)),<br>                paste(“Maximum height”, paste(H,”m”)),<br>                paste(“Descending time”, paste(T_2, “s”)),<br>                paste(“Total time”, paste(T_t,”s”)),<br>                paste(“Max. horizontal range”, paste(L,”m”))),<br>         cex=0.7, bg = par(“bg”))<br>  title(main = “Parabolic Shot”, sub = “From Origin &amp; Frictionless”)
<p>}<br><span><span lang="en"><span><b><br></b></span></span></span><span><br><span lang="en"><span>We test the function with a shot of 100 m / s of initial velocity and 45 degrees:</span></span></span><br><span><span lang="en"><span><b></b></span></span></span><br><span><span lang="en"><span><b><br>parabolic(100,45)</b></span></span></span></p></b>
<div><a target="_blank" rel="nofollow" href="https://i0.wp.com/4.bp.blogspot.com/-jLFhBBRq64A/WJD-4hE_8oI/AAAAAAAACv8/hC3B8oHNaVElNX6_ht4F-EoAMPz1UYc_ACLcB/s1600/Parabolic.png?ssl=1"><img src="https://i2.wp.com/4.bp.blogspot.com/-jLFhBBRq64A/WJD-4hE_8oI/AAAAAAAACv8/hC3B8oHNaVElNX6_ht4F-EoAMPz1UYc_ACLcB/s400/Parabolic.png?resize=400%2C277&ssl=1" border="0" data-recalc-dims="1"></a></div>
<p><span><span lang="en"><span><span lang="en"><span>In a following post we will do the simulation but with the effect of the air friction</span></span>.</span></span></span></p>
<p><span><span lang="en"><span><span lang="en"><span>If you want to use the function in another system of units, you only have to change the value of the acceleration of gravity g.</span></span> </span></span></span></p>
<p><span><span lang="en"><span>Get the script in:</span></span></span><br><span><span lang="en"><span><a target="_blank" rel="nofollow" href="https://github.com/pakinja/Data-R-Value/tree/master/Parabolic_Shot_Full">https://github.com/pakinja/Data-R-Value</a> </span></span></span></p>
<p><img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/DataRValue/~4/bPu8R05Uuo4"></p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://feedproxy.google.com/~r/DataRValue/~3/bPu8R05Uuo4/function-to-simulate-parabolic-shot.html"> Data R Value</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/H8D1p9NFv_w"></a></div></span></span></span>