<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/3-d-animations-with-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2017/08/3-d-animations-with-r.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>R is often used to visualize and animate 2-dimensional data. (Here are <a rel="nofollow" href="http://blog.revolutionanalytics.com/2017/05/tweenr.html" target="_blank">just</a> <a rel="nofollow" href="http://blog.revolutionanalytics.com/2016/02/japans-ageing-population-animated-with-r.html" target="_blank">a few</a> <a rel="nofollow" href="http://blog.revolutionanalytics.com/2017/03/the-rise-of-civilization-visualized-with-r.html" target="_blank">examples</a>.)  But did you know you can create 3-dimensional animations as well? </p>
<p>As Thomas Lins Pedersen explains in <a rel="nofollow" href="http://www.data-imaginist.com/2017/I-made-a-3D-movie/" target="_blank">a recent blog post</a>, the trick is in using the <code><a rel="nofollow" href="https://www.rdocumentation.org/packages/graphics/versions/3.4.0/topics/persp?tap_a=5644-dce66f&tap_s=10907-287229" target="_blank">persp</a></code> function to translate points in 3-D space into a 2-D projection. This function is normally used to render a 3-D scatterplot or wireframe plot, but if you instead capture its output value, it returns a transformation matrix. You can then use the <code><a rel="nofollow" href="https://www.rdocumentation.org/packages/grDevices/versions/3.4.1/topics/trans3d?tap_a=5644-dce66f&tap_s=10907-287229" target="_blank">trans3d</a></code> function to with this matrix to transform points in 3-D space. Thomas demonstrates how you can pass the transformed 2-D coordinates to plot a 3-D cube, and even animate it from two slightly different perspectives to create a 3-D stereo pair:</p>
<p><a rel="nofollow" href="http://www.data-imaginist.com/2017/I-made-a-3D-movie/" target="_blank"><img border="0" alt="Stereo-cube" title="Stereo-cube" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b8d2a547f9970c-800wi"></a></p>
<p>Rendering 3-D images isn't just for fun: there's plenty of 3-D data to analyze and visualize, too. Giora Simchoni used R to visualize data from the <a rel="nofollow" href="http://mocap.cs.cmu.edu/" target="_blank">Carnegie-Mellon Graphics Lab Motion Capture Database</a>. This data repository provides the output of human figures in motion-capture suits performing actions like walking, jumping, and even dancing. Since the motion-capture suits include multiple sensors measured over a time-period, the data structures are quite complex. To make things simpler, Giora created the <a rel="nofollow" href="https://github.com/gsimchoni/mocap" target="_blank">mocap</a> package (available on Github) to read these motion data files and generate 3-D animations to visualize them. For example, here's the output from two people performing the Charleston together:</p>
<p><a rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b8d2a548f8970c-pi" target="_blank"><img border="0" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b8d2a548f8970c-800wi" alt="Charleston" title="Charleston"></a></p>
<p>You can find complete details behind both animations, including the associated R code, at the links below.</p>
<p>Data Imaginist: <a rel="nofollow" href="http://www.data-imaginist.com/2017/I-made-a-3D-movie/" target="_blank">I made a 3D movie with ggplot2 once – here's how I did it</a><br>Giora Simchoni: <a rel="nofollow" href="http://giorasimchoni.com/2017/08/08/2017-08-08-lambada-the-mocap-package/" target="_blank">Lambada! (The mocap Package)</a></p>
</div>
	<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://blog.revolutionanalytics.com/2017/08/3-d-animations-with-r.html"> Revolutions</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 rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/6YOru8Alxtc" height="1"></a></div>