1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<META NAME="GENERATOR" CONTENT="Adobe FrameMaker 5.5/HTML Export Filter">
<LINK REL="STYLESHEET" HREF="VisualRef.css" CHARSET="ISO-8859-1" TYPE="text/css">
<TITLE> Description of Objects in VPython</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="ring.html"><img src="icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="index.html"><img src="icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="ellipsoid.html"><img src="icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Visual Reference</td>
<td><A HREF="index.html"><img src="icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="icons/blank.gif" border="0" height="32"
alt="" width="32"></td>
<td><img src="icons/blank.gif" border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="ring.html">The ring
Object</A> <b class="navlabel">Up:</b> <a class="sectref" HREF="index.html">Contents</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="ellipsoid.html">The ellipsoid
Object</A> <br>
<hr>
</DIV>
<DIV>
<H1 CLASS="Heading-1"> <font color="#0000A0">The box Object</font></H1>
</DIV>
<DIV>
<P CLASS="Normal">
In the first diagram we show a simple example of a box object:<IMG SRC="VisualRef-6.gif" ALIGN="RIGHT">
</P>
<DIV>
<H2 CLASS="program0">
mybox = box(pos=(x0,y0,z0), length=L, height=H, width=W) </H2>
<P CLASS="Normal"> The given position is in the center of the box, at (x0,
y0, z0). This is different from cylinder, whose pos attribute is at one
end of the cylinder. Just as with a cylinder, we can refer to the individual
vector components of the box as<span class="attribute"> mybox.x</span>,
<span class="attribute">mybox.y</span>, and <span class="attribute">mybox.z</span>.
The length (along the x axis) is L , the height (along the y axis) is H
, and the width is W (along the z axis). For this box, we have <span class="attribute">mybox.axis
= (L, 0, 0)</span> . Note that the axis of a box is just like the axis of
a cylinder. </P>
<P CLASS="Normal">
For a box that isn't aligned with the coordinate axes, additional issues come into play. The orientation of the length of the box is given by the axis (see second diagram):</P>
</DIV>
<DIV>
<H2 CLASS="program0">
mybox = box(pos=(x0,y0,z0), axis=(a,b,c), length=L,<BR>
height=H, width=W) </H2>
<P CLASS="Normal">
The axis attribute gives a direction for the length of the box, and the length, height, and width of the box are given as before (if a length attribute is not given, the length is set to the magnitude of the axis vector). </P>
<P CLASS="Normal"> There remains the issue of how to orient the box rotationally
around the specified axis. The rule that Visual uses is to orient the width
to lie in a plane perpendicular to the display "up" direction,
which by default is the y axis. Therefore in the diagram you see that the
width lies parallel to the x-z plane. The height of the box is oriented
perpendicular to the width, and to the specified axis of the box. It helps
to think of length initially as going along the x axis, height along the
y axis, and width along the z axis, and when the axis is tipped the width
stays in the x-z plane.</P>
<P CLASS="Normal">
You can rotate the box around its own axis by changing which way is "up" for the box, by specifying an up attribute for the box that is different from the up vector of the coordinate system:</P>
</DIV>
<DIV>
<H2 CLASS="program0">
mybox = box(pos=(x0,y0,z0), axis=(a,b,c), length=L,<BR>
height=H, width=W, up=(q,r,s))</H2>
<P CLASS="Normal">
With this statement, the width of the box will lie in a plane perpendicular to the (q,r,s) vector, and the height of the box will be perpendicular to the width and to the (a,b,c) vector.</P>
<P CLASS="Normal"> The box object has the following attributes and default
values, like those for cylinders: <span class="attribute">pos<font color="#000000">
(0,0,0)</font></span>, <span class="attribute">x</span><span class="attribute"><font color="#000000">
(0)</font></span>, <span class="attribute">y<font color="#000000">(0)</font></span>,
<span class="attribute">z<font color="#000000">(0)</font></span>, <span class="attribute">axis<font color="#000000">
(1,0,0)</font></span>, <span class="attribute">length<font color="#000000">
(1)</font></span>, <span class="attribute">color<font color="#000000"> (1,1,1)
which is color.white</font></span>, <span class="attribute">red<font color="#000000">
(1)</font></span>, <span class="attribute">green<font color="#000000"> (1)</font></span>,
<span class="attribute">blue<font color="#000000"> (1)</font></span>, and
<span class="attribute">up<font color="#000000"> (0,1,0)</font></span>.
Additional box attributes:</P>
<P CLASS="attributes"> <span class="attribute">height</span> In the y direction
in the simple case, default is 1</P>
<P CLASS="attributes"> <span class="attribute">width</span> In the z direction
in the simple case, default is 1</P>
<P CLASS="attributes"> <span class="attribute">size</span> (length, height,
width), default is (1,1,1)<BR>
<span class="attribute"> mybox.size=(20,10,12) </span>sets length=20, height=10,
width=12</P>
<P CLASS="Normal"> Note that the <span class="attribute">pos</span> attribute
for cylinder, arrow, cone, and pyramid corresponds to one end of the object,
whereas for a box, sphere, or ring it corresponds to the center of the object.
</P>
</DIV>
</DIV>
<DIV>
<H1 CLASS="Heading-1"><br>
</H1>
</DIV>
<hr>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="ring.html"><img src="icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="index.html"><img src="icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="ellipsoid.html"><img src="icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Visual Reference</td>
<td><A HREF="index.html"><img src="icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="icons/blank.gif" border="0" height="32"
alt="" width="32"></td>
<td><img src="icons/blank.gif" border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="ring.html">The ring
Object</A> <b class="navlabel">Up:</b> <a class="sectref" HREF="index.html">Contents</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="ellipsoid.html">The ellipsoid
Object</A> <br>
<hr>
</DIV>
</BODY>
</HTML>
|