|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" --> |
| 3 | +<head> |
| 4 | +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | +<!-- InstanceBeginEditable name="doctitle" --> |
| 6 | +<title>VPython Help</title> |
| 7 | +<!-- InstanceEndEditable --> |
| 8 | +<!-- InstanceBeginEditable name="head" --> |
| 9 | +<link href="VisualRef.css" rel="stylesheet" type="text/css" /> |
| 10 | +<style type="text/css"> |
| 11 | +<!-- |
| 12 | +.style1 {font-size: x-large} |
| 13 | +.style2 {font-size: xx-large} |
| 14 | +--> |
| 15 | +</style> |
| 16 | +<!-- InstanceEndEditable --> |
| 17 | +<script type="text/javascript"> |
| 18 | +<!-- |
| 19 | +function MM_jumpMenu(targ,selObj,restore){ //v3.0 |
| 20 | + eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); |
| 21 | + if (restore) selObj.selectedIndex=0; |
| 22 | +} |
| 23 | +//--> |
| 24 | +</script> |
| 25 | +<link href="VPythonDocs/VisualRef.css" rel="stylesheet" type="text/css" /> |
| 26 | +</head> |
| 27 | + |
| 28 | +<body> |
| 29 | +<table width="800" border="0" cellpadding="1" cellspacing="0"> |
| 30 | + <!--DWLayoutDefaultTable--> |
| 31 | + <tr> |
| 32 | + <td width="10" valign="top" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell--> </td> |
| 33 | + <td width="10" height="272" valign="top" bgcolor="#DDDDDD"><p> </p> </td> |
| 34 | + <td width="173" valign="top" bgcolor="#DDDDDD"><p class="Normal"><a href="index.html">Home</a></p> |
| 35 | + <p class="Normal">If you're new to Python <br /> |
| 36 | + and VPython: <a href="VisualIntro.html">Introduction</a></p> |
| 37 | + <p class="Normal">A VPython <a href="VPython_Intro.pdf" target="_blank">tutorial</a></p> |
| 38 | + <p class="Normal"><a href="primitives.html">Pictures</a> of 3D objects</p> |
| 39 | +<p><select id="menu1" onchange="jumpMenu(this)"></select></p> |
| 40 | +<p><select id="menu2" onchange="jumpMenu(this)"></select></p> |
| 41 | +<p><select id="menu3" onchange="jumpMenu(this)"></select></p> |
| 42 | + |
| 43 | + <p class="Normal">What's new in <a href="new_features.html">VPython 6</a></p> |
| 44 | + <p class="Normal"><a href="http://vpython.org" target="_blank">Classic VPython web site</a><br /> |
| 45 | + <a href="license.txt" target="_blank">VPython license</a><br /> |
| 46 | + <a href="http://www.python.org" target="_blank">Python web site</a> <br /></p></td> |
| 47 | + <td width="21" valign="top" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell--> </td> |
| 48 | + <td width="586" rowspan="2" valign="top"><!-- InstanceBeginEditable name="content" --> |
| 49 | + <div> |
| 50 | + <table width="100%" border="1"> |
| 51 | + <tr> |
| 52 | + <td width="78%"><div align="center"><span class="style1 style2"><font color="#0000A0">compound</font></span></div></td> |
| 53 | + <td width="22%"><div align="center"><img src="images/compound.jpg" alt="ring" width="137" height="138" /><a href="arrow.html"></a></div></td> |
| 54 | + </tr> |
| 55 | + </table> |
| 56 | + </div> |
| 57 | + <div> |
| 58 | + <p class="Normal">The <strong>compound</strong> object lets you group objects together and manage them as though they were one object, by specifying in the usual way <span class="attribute">pos</span>, <span class="attribute">color</span>, <span class="attribute">size</span>, <span class="attribute">axis</span>, <span class="attribute">up</span>, and <span class="attribute">texture</span>. Moreover, the display of a complicated compound object is faster than displaying the individual objects one at a time. The object shown above is a compound of a cylinder and a box:</p> |
| 59 | + <p class="program">handle = cylinder( size=vector(1,.2,.2), color=vector(0.72,0.42,0) )<br /> |
| 60 | + <br /> |
| 61 | + head = box( size=vector(.2,.6,.2), pos=vector(1.1,0,0), color=color.gray(.6) )<br /> |
| 62 | + <br /> |
| 63 | + hammer = compound([handle, head])<br /> |
| 64 | + hammer.axis = vector(1,1,0)</p> |
| 65 | + <p class="Normal">Note that after creating the hammer as a compound object, changing the axis rotates the combined object. The positions of the cylinder and box are relative to the origin, vec(0,0,0). If you set <span class="program"><strong>hammer.pos.x = 1</strong></span>, you move the hammer 1 unit to the right. The objects in a compound are "frozen". You can't change their attributes such as colors or orientations except as a group.</p> |
| 66 | + <p class="Normal">Setting <strong>hammer.color</strong> to something other than white makes a multiplicative blend of the overall color with the colors of the individual objects. For example, if the color of the handle is cyan, vec(0,1,1), and the hammer color is yellow, vec(1,1,0), the blend results in vec(0*1, 1*1, 0*0) or vec(0,1,0), which is green.</p> |
| 67 | + <p class="Normal"><strong><font color="#0000a0">Setting parameters when creating a compound</font></strong></p> |
| 68 | + <p class="Normal">You can optionally specify parameters for a compound. The following statement is equivalent to creating the hammer, then changing the axis:</p> |
| 69 | + <p class="program">hammer = compound( [handle, head],<br /> |
| 70 | + axis=vector(1,1,0) ) </p> |
| 71 | + <p class="Normal"><strong><font color="#0000a0">Compound and world coordinates</font></strong></p> |
| 72 | + <p class="Normal">There are two functions for translating between compound and world coordinates, which may differ if the compound object has been moved or rotated. Suppose the name of the compound is <strong>c</strong>, <strong>c_pos</strong> is a position within that compound, and <strong>world_pos</strong> is the corresponding position in world coordinates:</p> |
| 73 | + <p class="program">world_pos = c.compound_to_world(c_pos)</p> |
| 74 | + <p class="program">c_pos = c.world_to_compound(world_pos) </p> |
| 75 | + <p class="Normal"><strong><font color="#0000a0">Current restrictions</font></strong></p> |
| 76 | + <p class="Normal">Currently objects in a compound can have their own colors and opacities but they cannot have individual textures or bumpmaps, which can only be specified for the combined object, and which affect all of the compounded objects.</p> |
| 77 | + <p class="Normal">Currently label objects and objects based on curve objects (curve, helix) cannot be compounded. However, <a href="triangle.html">triangles</a>, <a href="triangle.html">quads</a>, and even other compounds can be compounded.</p> |
| 78 | + <!-- InstanceEndEditable --></td> |
| 79 | + </tr> |
| 80 | + <tr> |
| 81 | + <td height="16" colspan="4"></td> |
| 82 | + </tr> |
| 83 | +</table> |
| 84 | +</body> |
| 85 | +<script type="text/javascript" language="javascript" src="navigation.js"></script> |
| 86 | +<!-- InstanceEnd --></html> |
0 commit comments