Skip to content

Commit

Permalink
added matlab code
Browse files Browse the repository at this point in the history
  • Loading branch information
Trexter committed Apr 27, 2018
1 parent 75111f3 commit 2d1b707
Show file tree
Hide file tree
Showing 36 changed files with 3,754 additions and 0 deletions.
1,385 changes: 1,385 additions & 0 deletions matlab/TrajectoryGenerator/arrow.m

Large diffs are not rendered by default.

805 changes: 805 additions & 0 deletions matlab/TrajectoryGenerator/arrow3.m

Large diffs are not rendered by default.

869 changes: 869 additions & 0 deletions matlab/TrajectoryGenerator/arrow3/arrow3_examples.html

Large diffs are not rendered by default.

273 changes: 273 additions & 0 deletions matlab/TrajectoryGenerator/arrow3/arrow3_messes_up_my_plots.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Arrow3 Messes Up My Plots!</title>
<meta name="author" content="Arrow3 Apologist">
<link type="text/css" rel="stylesheet" href="text.css">
</head>
<body>
<h2 style="text-align: center; color: rgb(102, 0, 0);">ARROW3&nbsp;
MESSES&nbsp; UP&nbsp; MY&nbsp; PLOTS!<br>
A Dialog Between a Reasonable
User and an Arrow3 Apologist</h4>
<table style="width: 600px;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Reasonable
User:</span>&nbsp; Why should I use Arrow3 when there are many other
solutions on the File Exchange, most notably Erik Johnson's <a
href="http://www.mathworks.com/matlabcentral/fileexchange/278">Arrow.m</a>?</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Arrow3
Apologist:</span>&nbsp; Arrow.m is an excellent tool for labeling
because it draws two-dimensional patches in a plane.&nbsp; <a
href="http://www.mathworks.com/matlabcentral/fileexchange/14056">Arrow3.m</a>,
on the other hand, draws cones and spheres in 3-space.&nbsp; The
programmer says it draws an "astonishing" number of vectors with a
"bewildering" variety of colors in "practically no time at all," and
that it "looks real pretty when you twirl 'em around."</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Reasonable
User:</span>&nbsp; That is not what I want to do.</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Arrow3
Apologist:</span>&nbsp;
Oh, OK.&nbsp; Sorry.</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Reasonable
User:</span>&nbsp;
I want to use Arrow3 to indicate the path of a
particle that moves along the helix in fig. 1.</div>
</td>
</tr>
</tbody>
</table>
<br>
<div style="margin-left: 38px;">
<div class="code" style="width:562px;"><code>t=0:pi/40:8*pi;<br>
plot3(20*t,cos(t),sin(t))<br>
axis([0,600,-1.5,1.5,-1.5,1.5])<br>
grid <span style="color: rgb(160, 32, 240);">on</span>, view(35,40)<br>
</code>
</div>
<br>
<table style="text-align: left; width: 560px;" border="0"
cellpadding="0">
<caption align="bottom">Figure 1.<br>
</caption><tbody>
<tr>
<td style="padding:0px;"><img src="fig01.png" alt="Figure 1." title="Figure 1."
style="border: 1px solid ; width: 560px; height: 420px;" vspace="7"></td>
</tr>
</tbody>
</table>
</div>
<br>
<table style="width: 600px;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Arrow3
Apologist:</span>&nbsp;
Well OK, but it's gonna mess up your plot because you didn't fix the
aspect
ratio.</div>
</td>
</tr>
</tbody>
</table>
<br>
<div style="margin-left: 38px;">
<div class="code" style="width:562px;"><code>t=0:pi/40:8*pi;<br>
plot3(20*t,cos(t),sin(t))<br>
axis([0,600,-1.5,1.5,-1.5,1.5])<br>
grid <span style="color: rgb(160, 32, 240);">on</span>, view(35,40)<br>
hold <span style="color: rgb(160, 32, 240);">on</span><br>
arrow3([0,0,0],[600,0,0],<span style="color: rgb(160, 32, 240);">''</span>,2,[],0)<br>
hold <span style="color: rgb(160, 32, 240);">off</span><br>
</code>
</div>
<br>
<table style="text-align: left; width: 560px;" border="0"
cellpadding="0">
<caption align="bottom">Figure 2.<br>
</caption><tbody>
<tr>
<td style="padding:0px;"><img src="fig02.png" alt="Figure 2." title="Figure 2."
style="border: 1px solid ; width: 560px; height: 420px;" vspace="7"></td>
</tr>
</tbody>
</table>
</div>
<br>
<table style="width: 600px;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Reasonable
User:</span>&nbsp;
Fig. 2 does not look anything like fig. 1.</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Arrow3
Apologist:</span>&nbsp;
Sure it does ... sort of.&nbsp; Arrow3 is graphically similar to the
<font style="font-family:monospace">coneplot</font>
function:&nbsp; only with a fixed aspect ratio can the
surfaces be properly rendered.&nbsp; Arrow3 overrides stretch-to-fill
behavior by setting DataAspectRatioMode, PlotBoxAspectRatioMode, and
CameraViewAngleMode to manual.&nbsp; You can restore stretch-to-fill
scaling with <font style="font-family:monospace">axis normal</font>,
but that will warp the surfaces.</div>
</td>
</tr>
</tbody>
</table>
<br>
<div style="margin-left: 38px;">
<div class="code" style="width:562px;"><code>t=0:pi/40:8*pi;<br>
plot3(20*t,cos(t),sin(t))<br>
axis([0,600,-1.5,1.5,-1.5,1.5])<br>
grid <span style="color: rgb(160, 32, 240);">on</span>, view(35,40)<br>
hold <span style="color: rgb(160, 32, 240);">on</span><br>
arrow3([0,0,0],[600,0,0],<span style="color: rgb(160, 32, 240);">''</span>,2,[],0)<br>
hold <span style="color: rgb(160, 32, 240);">off</span><br>
axis <span style="color: rgb(160, 32, 240);">normal</span><br>
</code>
</div>
<br>
<table style="text-align: left; width: 560px;" border="0"
cellpadding="0">
<caption align="bottom">Figure 3.<br>
</caption><tbody>
<tr>
<td style="padding:0px;"><img src="fig03.png" alt="Figure 3." title="Figure 3."
style="border: 1px solid ; width: 560px; height: 420px;" vspace="7"></td>
</tr>
</tbody>
</table>
</div>
<br>
<table style="width: 600px;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Reasonable
User:</span>&nbsp;
Now the arrowhead and origin marker are distorted.</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Arrow3
Apologist:</span>&nbsp;
Yep, they're squished.&nbsp; If you set <font style="font-family:monospace">pbaspect</font>
and change <font style="font-family:monospace">view</font>, you can get a plot with a manual aspect
ratio that fills the plot box in much the same fashion as fig. 1.</div>
</td>
</tr>
</tbody>
</table>
<br>
<div style="margin-left: 38px;">
<div class="code" style="width:562px;"><code>t=0:pi/40:8*pi;<br>
plot3(20*t,cos(t),sin(t))<br>
axis([0,600,-1.5,1.5,-1.5,1.5])<br>
grid <span style="color: rgb(160, 32, 240);">on</span>, view(35,25)<br>
hold <span style="color: rgb(160, 32, 240);">on</span><br>
pbaspect([1.8,1.4,1])<br>
<span style="color: rgb(34, 139, 34);">% similar results may be
obtained by using</span><br style="color: rgb(34, 139, 34);">
<span style="color: rgb(34, 139, 34);">% daspect([111,0.7,1])</span><br>
arrow3([0,0,0],[600,0,0],<span style="color: rgb(160, 32, 240);">''</span>,1.25,[],0)<br>
hold <span style="color: rgb(160, 32, 240);">off</span><br>
</code>
</div>
<br>
<table style="text-align: left; width: 560px;" border="0"
cellpadding="0">
<caption align="bottom">Figure 4.<br>
</caption><tbody>
<tr>
<td style="padding:0px;"><img src="fig04.png" alt="Figure 4." title="Figure 4."
style="border: 1px solid ; width: 560px; height: 420px;" vspace="7"></td>
</tr>
</tbody>
</table>
</div>
<br>
<table style="width: 600px;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Reasonable
User:</span>&nbsp; Why doesn't the
program accommodate stretch-to-fill
scaling automatically?</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Arrow3
Apologist:</span>&nbsp;
I asked the programmer, and he said that the stretch-to-fill thing is
"really hard" and "awfully
complicated."&nbsp; Personally, I think he just can't figure it out.</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Reasonable
User:</span>&nbsp;
Alright, but what I really wanted was low-impact coordinate axes with
dark blue little arrows at quarter pi increments along the helix.</div>
<br>
<div class="indent"><span
style="color: rgb(102, 0, 0); font-style: italic;">Arrow3
Apologist:</span>&nbsp;
Oh, OK.&nbsp; Sorry.</div>
</td>
</tr>
</tbody>
</table>
<br>
<div style="margin-left: 38px;">
<div class="code" style="width:562px;"><code>t=(0:pi/40:8*pi)';
u=cos(t); v=sin(t);<br>
plot3(20*t,u,v)<br>
axis([0,600,-1.5,1.5,-1.5,1.5])<br>
grid <span style="color: rgb(160, 32, 240);">on</span>, view(35,25)<br>
hold <span style="color: rgb(160, 32, 240);">on</span><br>
pbaspect([1.8,1.4,1])<br>
arrow3(zeros(3),diag([500,1.5,1.5]),<span
style="color: rgb(160, 32, 240);">'l'</span>,0.7,[],0)<br>
p=[20*t,u,v]; ndx=11:10:length(t);<br>
p2=p(ndx,:); p1=p(ndx-3,:);<br>
arrow3(p1,p2,<span style="color: rgb(160, 32, 240);">'0_b'</span>,0.7)<br>
hold <span style="color: rgb(160, 32, 240);">off</span><br>
</code>
</div>
<br>
<table style="text-align: left; width: 560px;" border="0"
cellpadding="0">
<caption align="bottom">Figure 5.<br>
</caption><tbody>
<tr>
<td style="padding:0px;"><img src="fig05.png" alt="Figure 5." title="Figure 5."
style="border: 1px solid ; width: 560px; height: 420px;" vspace="7"></td>
</tr>
</tbody>
</table>
<br>&nbsp;
<br>
See also <a href="arrow3_examples.html#Update">Example 16.</a><br>
<br>
<br>
</div>
</body>
</html>
Binary file added matlab/TrajectoryGenerator/arrow3/ex01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex16a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex16b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/ex16c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/fig01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/fig02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/fig03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/fig04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added matlab/TrajectoryGenerator/arrow3/fig05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions matlab/TrajectoryGenerator/arrow3/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2009, Erik A Johnson
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
35 changes: 35 additions & 0 deletions matlab/TrajectoryGenerator/arrow3/text.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
body {
font-size: 10pt;
font-weight: normal;
font-family: sans-serif;
color: black;
background: white;}
table, td, th {
border-collapse: collapse;
font-size: 10pt;
font-weight: normal;
font-family: sans-serif;
color: black;
background: white;}
tr {
vertical-align: top;}
div.code {
width: 562px;
font-size: 10pt;
font-weight: normal;
font-family: monospace;
color: black;
background-color: rgb(238, 238, 238);}
div.indent {
font-size: 10pt;
margin-left: 38px;
text-indent: -38px;}
h2 {
font-size: 12pt;
width: 600px;}
a:visited {color: black;}
a:link {color: black;}
a:active {color: black;}
a:hover {color: black;
background: yellow;
text-decoration: none;}
Loading

0 comments on commit 2d1b707

Please sign in to comment.