Standard Draw 3D - Princeton University

Transcription

Standard Draw 3DComplete Reference ManualHayk MartirosyanIntroductionStandard Draw 3D is a Java library with the express goal of making it simple to create threedimensional models, simulations, and games. If you have not used StdDraw3D before, make sure togo through the basic tutorial before coming here.This document is the official reference manual for Standard Draw 3D. Listed below is every methodin the library, categorized by functionality. Most of the library is in the form of static methods, butthere are also nested classes that are crucial to the way StdDraw3D works.Table of ContentsEach section of the table of contents is hyperlinked to the corresponding section of the manual.Static MethodsGeneral Settingsè Canvas Sizeè Scaleè Perspectiveè Mesh Controlè Info Displayè Anti-AliasingPen Settingsè Pen Colorè Pen Radiusè Pen FontBackgroundè Solid Colorè Imageè Spherical PanoramaBasic 3D Shapesè Sphereè Cubeè BoxPrinted by Mathematicafor Students

2 Standard Draw 3D Referenceè Coneè Cylinderè EllipsoidAdvanced 3D Shapesè 3D Textè Tubesè External ModelDisplay and Animationè Showingè ClearingStatic Camera Placementè Camera Position and Orientationè Camera DirectionInteractive Navigationè Mode Descriptionsè Setting the Camera Modeè Orbit CenterPoints, Lines, and Surfacesè Pointsè Linesè Polygonsè TrianglesSaving and Loadingè Image Fileè 3D SceneLightsè Light Utilitiesè Ambient Lightè Point Lightè Directional Lightè FogSoundsè Sound Utilitiesè Ambient Soundè Point SoundMouse and Keyboardè Mouse Buttonsè Mouse Positionè Key Pressedè Key Stack2D Overlayè CirclePrinted by Mathematicafor Students

Standard Draw 3D Reference intLineArcPolygonTextPictureRandom Generatorsè Colorè Vector DirectionShape ClassStatic Shape Manipulationè Combineè CopyPositionè Move Absoluteè Move Relativeè Set PositionOrientationè Rotate Absoluteè Rotate Relativeè Set Orientationè Rotate about Axisè Look Atè Set DirectionSizeColorMatchingHidingCamera ClassGetting the Camera ObjectMethods from Shape ClassAdditional Methodsè Pairè Rotate FPSPrinted by Mathematicafor Students

4 Standard Draw 3D ReferenceLight ClassMethods from Shape ClassPower of a Point LightVector3D ClassFieldsConstructorsMethodsè Additionè Subtractionè Multiplicationè Magnitudeè Directionè Distanceè Dot Productè Cross Productè Angleè Projectionè Reflectionè To Stringè DrawPrinted by Mathematicafor Students

Standard Draw 3D Reference 5STATIC METHODSThese static functions are called by prefixing the method name with “StdDraw3D.”. For example,to draw a sphere, call StdDraw3D.sphere(x, y, z, r). Nested classes of StdDraw3D are documentedbelow this section.General SettingsGlobal settings of StdDraw3D are included here, and control various aspects of the drawing windowand rendering process. Canvas size and scale should be defined at the start of each project.Canvas SizeSets the drawing window size to (w, h) pixels. Can also set the drawing window to fullscreen, whichmakes it as large as possible to fit the displaying monitor.All ArgumentsTypeName Descriptiondouble wwidthdouble hheightMethodssetCanvasSize Hw, hLfullscreenHLReturn Type NamevoidvoidArgumentsScaleThe “scale” of the drawing window is important to the way StdDraw3D works. In general, it is thecoordinate range which you are likely to be drawing in (for all three dimensions). In your drawingwindow, is by default placed such that you can see the working volume specified by the setScale()function. Of course you can move the camera as desired, but navigation speed is also calibratedbased on the scale, so it is useful to set a good scale. Calling setScale() without arguments reverts tothe default scale of (0, 1).ArgumentsTypeNameDescriptiondouble minimum the minimum x, y, and z coordinate of your working volumedouble maximum the maximum x, y, and z coordinate of your working volumeMethodssetScale Hminimum, maximumLsetScale HLReturn Type NamevoidvoidArgumentsPrinted by Mathematicafor Students

6 Standard Draw 3D ReferencePerspectiveThe perspective of a 3D scene is the way it is projected onto a 2D computer monitor to create theappearance of three-dimensional depth. Objects that are closer appear larger in real life, and this ishow they are drawn in StdDraw3D. This is called perspective projection, and the amount to whichcloser objects appear larger is proportional to the field of view. You can specify the field of viewwith the setPerspectiveProjection() function, or revert to the default of 0.9. A large field of viewlooks like a fisheye, while a small field of view is like looking through a telescope. Reasonablevalues of fov range from 0.5 to 3.0. Zero perspective can be set with setParallelProjection(), and ishow all CAD programs display 3D objects.ArgumentsTypeName Descriptiondouble fov field of view of perspective projectionMethodssetPerspectiveProjection HfovLsetPerspectiveProjection HLsetParallelProjectionHLReturn Type NamevoidvoidvoidArgumentsMesh ControlSets the number of trianglular divisions of curved shapes like spheres and cylinders. The default is100 divisons. Decrease this number to increase performance. Can also get the current value.ArgumentsType Name Descriptionint Nnumber of triangular divisionsMethodssetNumDivisions HNLgetNumDivisions HLReturn Type NamevoidintArgumentsInfo DisplayToggles the information display in the upper-left corner.ArgumentsTypeNameDescriptionboolean enabled state of the info displayMethodssetInfoDisplay HenabledLReturn Type NamevoidArgumentsAnti-AliasingToggles simple anti-aliasing. Anti-aliasing makes graphics look much smoother, but is very resourcePrinted by Mathematicafor Studentsheavy. It is good for saving imagesthat look professional. The default is off. Currently notsupported for OS-X, and only works with some PCs. Can also get the current state.

Standard Draw 3D Reference 7Toggles simple anti-aliasing. Anti-aliasing makes graphics look much smoother, but is very resourceheavy. It is good for saving images that look professional. The default is off. Currently notsupported for OS-X, and only works with some PCs. Can also get the current state.ArgumentsTypeNameDescriptionboolean enabled state of anti - aliasingMethodssetAntiAliasing HenabledLgetAntiAliasing HLReturn Type NamevoidbooleanArgumentsPen SettingsThese functions change the propreties of the drawing pen, which influences the properties of thingsyou draw. For example, a drawn sphere will be the pen color, a drawn line will have the pen radius,and drawn text will have the pen font.Pen ColorSets the pen to the given color. Can specify either a color, a color and a transparency, RGBcomponents, or nothing (reverts to the default pen color). Can also get the current pen color.All iptiondesired coloroptional transparency of color H0 - 255Lred component of an RGB colorgreen component of an RGB colorblue component of an RGB colorMethodsReturn Type NamevoidvoidvoidvoidColorHcolLHcol, alphaLHr, g, tPenColorgetPenColorPen RadiusSets the pen stroke to the given radius, or reverts to the default of 0.002 if no arguments are given.Can also get the current radius.ArgumentsTypeName Descriptiondouble rdesired pen radiusPrinted by Mathematicafor Students

8 Standard Draw 3D ReferenceMethodssetPenRadius HrLsetPenRadius HLgetPenRadius HLReturn Type NamevoidvoidfloatArgumentsPen FontSets the pen to the given Font object, or reverts to the default if no arguments are given. Can alsoget the current font.All ArgumentsType Name DescriptionFont fdesired pen fontMethodssetFont HfLsetFont HLgetFont HLReturn Type NamevoidvoidFontArgumentsBackgroundThe background of the drawing window is by black by default, but can be easily changed as needed.There are three options for specifying a background: you can set a solid color, a background image,or an image wrapped around a 3D background sphere.Solid ColorSets the background to a solid color.ArgumentsType Name DescriptionColor color desired colorMethodssetBackground HcolorLReturn Type NamevoidArgumentsImageSets the background to a specified image, which is scaled to fit the window.ArgumentsTypeNameDescriptionString imageURL filename or URL of desired background imageMethodsReturn Type NameArgumentsPrinted by Mathematicafor Students

Standard Draw 3D Reference 9setBackground HimageURLLvoidSpherical PanoramaSets the background to a specified image, wrapped around as a spherical skybox.ArgumentsTypeNameDescriptionString imageURL filename or URL of desired background imageMethodssetBackgroundSphere HimageURLLReturn Type NamevoidArgumentsBasic 3D ShapesThere are six basic three-dimensional shapes in StdDraw3D: spheres, cubes, boxes, cones,cylinders, and ellipsoids. Each primitive shape has a set of five drawing functions, depending onwhether you want to specify rotation, texture, or wireframe properties. Sphere and cube are specificcases of ellipsoid and box, but are included for convenience. Every drawing function returns aShape object, which can be moved, rotated, and scaled dynamically using the methods of the Shapeclass.SphereDraws a sphere at (x, y, z) with radius r. Can specify Euler rotation angles (xA, yA, zA). Can besolid, wireframe, or textured.All oubleStringNamexyzrxAyAzAimageURLDescriptionx - coordinate of the centery - coordinate of the centerz - coordinate of the centerradiusx component of XYZ Euler angle rotationy component of XYZ Euler angle rotationz component of XYZ Euler angle rotationfilename or URL of wraparound textureReturn ValueReturns the drawn Shape object, which can be further manipulated.Solidsphere Hx, y, z, rLsphere Hx, y, z, r, xA, yA, zALReturn Type NameShapeShapeArgumentsWireframePrinted by Mathematicafor Students

10 Standard Draw 3D ReferencewireSphere Hx, y, z, rLwireSphere Hx, y, z, r, xA, yA, zALReturn Type NameShapeShapeArgumentsTexturedsphere Hx, y, z, r, xA, yA, zA, imageURLLReturn Type NameShapeArgumentsCubeDraws a cube at (x, y, z) with radius r. Can specify Euler rotation angles (xA, yA, zA). Can besolid, wireframe, or textured.All oubleStringNamexyzrxAyAzAimageURLDescriptionx - coordinate of the centery - coordinate of the centerz - coordinate of the centerradius Hhalf of side lengthLx component of XYZ Euler angle rotationy component of XYZ Euler angle rotationz component of XYZ Euler angle rotationfilename or URL of wraparound textureReturn ValueReturns the drawn Shape object, which can be further manipulated.Solidcube Hx, y, z, rLcube Hx, y, z, r, xA, yA, zALReturn Type Name ArgumentsShapeShapeWireframewireCube Hx, y, z, rLwireCube Hx, y, z, r, xA, yA, zALReturn Type NameShapeShapeArgumentsTexturedcube Hx, y, z, r, xA, yA, zA, imageURLLReturn Type Name ArgumentsShapeBoxDraws a box at (x, y, z) with dimensions (w, h, d). Can specify Euler rotation angles (xA, yA, zA).Can be solid, wireframe, or textured.All ArgumentsTypeNamedouble xdouble yDescriptionx - coordinate of the centery - coordinate of the centerPrinted by Mathematicafor Students

Standard Draw 3D Reference zwhdxAyAzAimageURLz - coordinate of the centerwidthheightdepthx component of XYZ Euler angle rotationy component of XYZ Euler angle rotationz component of XYZ Euler angle rotationfilename or URL of wraparound textureReturn ValueReturns the drawn Shape object, which can be further manipulated.SolidHx, y, z, w, h, dLHx, y, z, w, h, d, xA, yA, zALReturn Type Name ArgumentsShapeShapeboxboxWireframewireBox Hx, y, z, w, h, dLwireBox Hx, y, z, w, h, d, xA, yA, zALReturn Type NameShapeShapeArgumentsTexturedHx, y, z, w, h, d, xA, yA, zA, imageURLLReturn Type Name ArgumentsShapeboxConeDraws a cone at (x,y,z) with radius r and height h. Can specify Euler rotation angles (xA, yA, zA).Can be solid, wireframe, or textured.All nx - coordinate of the centery - coordinate of the centerz - coordinate of the centerradiusheightx component of XYZ Euler angle rotationy component of XYZ Euler angle rotationz component of XYZ Euler angle rotationfilename or URL of wraparound textureReturn ValueReturns the drawn Shape object, which can be further manipulated.Solidcone Hx, y, z, r, hLcone Hx, y, z, r, h, xA, yA, zALReturn Type Name ArgumentsShapeShapePrinted by Mathematicafor Students

12 Standard Draw 3D ReferenceWireframewireCone Hx, y, z, r, hLwireCone Hx, y, z, r, h, xA, yA, zALReturn Type NameShapeShapeArgumentsTexturedcone Hx, y, z, r, h, xA, yA, zA, imageURLLReturn Type Name ArgumentsShapeCylinderDraws a cylinder at (x,y,z) with radius r and height h. Can specify Euler rotation angles (xA, yA,zA). Can be solid, wireframe, or textured.All nx - coordinate of the centery - coordinate of the centerz - coordinate of the centerradiusheightx component of XYZ Euler angle rotationy component of XYZ Euler angle rotationz component of XYZ Euler angle rotationfilename or URL of wraparound textureReturn ValueReturns the drawn Shape object, which can be further manipulated.Solidcylinder Hx, y, z, r, hLcylinder Hx, y, z, r, h, xA, yA, zALReturn Type NameShapeShapeArgumentsWireframewireCylinder Hx, y, z, r, hLwireCylinder Hx, y, z, r, h, xA, yA, zALReturn Type NameShapeShapeArgumentsTexturedcylinder Hx, y, z, r, h, xA, yA, zA, imageURLLReturn Type NameShapeArgumentsEllipsoidDraws an ellipsoid at (x, y, z) with dimensions (w, h, d). Can specify Euler rotation angles (xA, yA,zA). Can be solid, wireframe, or textured.All ArgumentsTypeNamedouble xDescriptionx - coordinateof the centerPrinted by Mathematicafor Students

Standard Draw 3D Reference StringyzwhdxAyAzAimageURLy - coordinate of the centerz - coordinate of the centerwidthheightdepthx component of XYZ Euler angle rotationy component of XYZ Euler angle rotationz component of XYZ Euler angle rotationfilename or URL of wraparound textureReturn ValueReturns the drawn Shape object, which can be further manipulated.Solidellipsoid Hx, y, z, w, h, dLellipsoid Hx, y, z, w, h, d, xA, yA, zALReturn Type NameShapeShapeArgumentsWireframewireEllipsoid Hx, y, z, w, h, dLwireEllipsoid Hx, y, z, w, h, d, xA, yA, zALReturn Type NameShapeShapeArgumentsTexturedellipsoid Hx, y, z, w, h, d, xA, yA, zA, imageURLLReturn Type NameShapeArgumentsAdvanced 3D ShapesThese more complicated 3D objects are useful in many cases. Every drawing function returns aShape object, which can be moved, rotated, and scaled dynamically using the methods of the Shapeclass.3D TextDraws 3D text of the given string at (x, y, z) with the pen font. Can specify Euler rotation angles(xA, yA, zA). Uses the pen font, color, and doubledoubledoubleNamexyztextxAyAzADescriptionx - coordinate of the centery - coordinate of the centerz - coordinate of the centerthe text to be shownx component of XYZ Euler angle rotationy component of XYZ Euler angle rotationz component of XYZ Euler angle rotationPrinted by Mathematicafor Students

14 Standard Draw 3D ReferenceReturn ValueReturns the drawn Shape object, which can be further manipulated.Methodstext3D Hx, y, z, textLtext3D Hx, y, z, text, xA, yA, zALReturn Type NameShapeShapeArgumentsTubesDraws a solid 3D cylindrical tube or a set of tubes with the given start and end coordinates andradius. Drawing a set of tubes is not much more efficient than drawing individual tubes, but willcompact code. Can specify a set of colors for the set of tubes.All z2xyzrcolorsDescriptionx - coordinate of the start pointy - coordinate of the start pointz - coordinate of the start pointx - coordinate of the end pointy - coordinate of the end pointz - coordinate of the end pointset of x - coordinates of the tube verticesset of y - coordinates of the tube verticesset of z - coordinates of the tube verticesradius of the tubeset of colors that correspond to the set of tubesReturn ValueReturns the drawn Shape object, which can be further manipulated.Single Tubetube Hx1, y1, z1, x2, y2, z2, rLReturn Type Name ArgumentsShapeSet of Tubestubes Hx, y, z, rLtubes Hx, y, z, r, colorsLReturn Type NameShapeShapeArgumentsExternal ModelYou can easily import .OBJ (preferred) or .PLY models into your scene as Shape objects. It takessome time to create a mesh for larger models with millions of triangles. Colors and textures of anOBJ file can be imported by including the .mtl material template library. Can also import the modelas a Shape with a single color (the pen color), and change the color using the Shape class. ImportedOBJ models can be automatically scaled to have an average radius of 1, or keep their original size(default).by MathematicaStudentson old OBJ standards and often doesn’tNote: The Java loader used toPrintedimportOBJ files foris basedwork properly for textures and newer commands in the OBJ file.

Standard Draw 3D Reference 15Note: The Java loader used to import OBJ files is based on old OBJ standards and often doesn’twork properly for textures and newer commands in the OBJ file.ArgumentsTypeNameDescriptionString filename filename of the model to importboolean resizeresizes the model if trueReturn ValueReturns the drawn Shape object, which can be further manipulated.MethodsReturn Type NameShapeShapeShapeShapeHfilenameLHfilename, resizeLHfilenameLHfilename, Display and AnimationThe basic tools needed to display and animate a 3D scene are these functions for clearing orshowing objects in the drawing window. If you are drawing a single scene without moving objects,just call finished() once after you are done drawing. If you are animating, call show() to displayeach frame with the desired framerate and clear() to clear the drawing window when desired. Youcan also clear just the 3D scene or just the 2D overlay, to enable independence between the two.ShowingShow functions render everything to the drawing window, then pause for the given number ofmilliseconds. If no argument is provided, renders to the screen but does not pause. Methods are alsoprovided to show just the 3D scene or to show just the 2D overlay. finished() is equivalent toshow(infinity).ArgumentsType Name Descriptionint time pauses for this many milliseconds after displayingMethodsReturn Type verlayshowOverlayPrinted by Mathematicafor Students

16 Standard Draw 3D ReferenceClearingClears the drawing window upon the next call of show. Methods are also provided to clear just the3D scene or to clear just the 2D overlay.ArgumentsType Name DescriptionColor color if provided, sets as the background color after clearingMethodsReturn Type arclear3DclearOverlayStatic Camera PlacementThe simplest way to programmatically place the camera where you want is to use these staticcamera methods. For more advanced camera control, learn how to use and manipulate the Cameraobject.Camera Position and OrientationSets the camera position and orientation. Orientation is represented by XYZ Euler rotation angles.These numbers correspond to those shown in the info display on the upper-left corner of the drawingwindow. Can specify scalar or vector input. Can also get the current position and orientation.All glesDescriptionx - coordinate of camera positiony - coordinate of camera positionz - coordinate of camera positionposition vector, represents 8x, y, z x component of XYZ Euler angle rotationy component of XYZ Euler angle rotationz component of XYZ Euler angle rotationorientation vector, represents 8xAngle, yAngle, zAngle PositionsetCameraPosition Hx, y, zLsetCameraPosition HpositionLgetCameraPosition HLReturn Type NamevoidvoidVector3DArgumentsOrientationReturn Type NameArgumentsPrinted by Mathematicafor Students

Standard Draw 3D Reference 17setCameraOrientation HxAngle, yAngle, zAngleLsetCameraOrientation HanglesLgetCameraOrientation HLvoidvoidvoidBothsetCamera Hx, y, z, xAngle, yAngle, zAngleLsetCamera Hposition, anglesLReturn Type NamevoidvoidArgumentsCamera DirectionInstead of specifying orientation by Euler angles, it is easier in many cases to specify the vectordirection in which the camera should point. For example, (0,1,0) would cause the camera to rotatesuch that it looks along the positive y-axis. Input is normalized. Can specify scalar or vector input.Can also get the current camera direction.All ctionDescriptionx - component of camera direction vectory - component of camera direction vectorz - component of camera direction vectorcamera direction vector, same as 8x, y, z PositionsetCameraDirection Hx, y, zLsetCameraDirection HdirectionLgetCameraDirection HLReturn Type NamevoidvoidVector3DArgumentsInteractive NavigationIn StdDraw3D, you can move and navigate through the 3D scene interactively using mouse andkeyboard controls. The five camera navigation modes and their controls are described below. If youare creating your own set of controls, use FIXED MODE to disable interactivity. The camera modecan also be changed through the GUI menu, and with the keyboard shortcuts listed in that menu.Mode DescriptionsStdDraw3D.ORBIT MODERotates and zooms about a central orbit center, which is the origin by default but can be changed.PrimarySecondary EffectLeft Mouse DragOrbitRight Mouse DragPanMouse WheelAlt DragZoomStdDraw3D.FPS MODEFirst-person-shooter style controls with arrow keys and WASD to move and mouse to look. Thepositive y-axis is always upward.Printed by Mathematicafor Students

18 Standard Draw 3D ReferenceFirst-person-shooter style controls with arrow keys and WASD to move and mouse to look. Thepositive y-axis is always upward.PrimaryUp ArrowLeft ArrowDown ArrowRight ArrowPage UpPage DownMouse pDownLookStdDraw3D.AIRPLANE MODESimilar to FPS MODE, but the y-axis is not always upward, and can be rotated with Q and E.PrimaryUp ArrowLeft ArrowDown ArrowRight ArrowPage UpPage DownMouse otate CCWRotate CWLookStdDraw3D.LOOK MODENo interactive movement is allowed, but uses the mouse drag to look around.PrimarySecondary EffectMouse DragLookStdDraw3D.FIXED MODENo interactive camera control is allowed. Use this if you want to only programmatically move yourcamera, or if you are defining your own set of navigation controls.Setting the Camera ModeSets the camera navigation mode. If no argument is specified, reverts to the default ofORBIT MODE. Can also get the current mode.ArgumentsType Name Descriptionint mode one of the defined camera modesMethodssetCameraMode HmodeLsetCameraMode HLgetCameraMode HLReturn Type NamevoidvoidintArgumentsOrbit CenterORBIT MODE is the default mode, in which dragging with the left mouse button orbits about asingle point. This is the originPrintedby default,but canforbeStudentschanged. Can specify scalar or vector input.by MathematicaCan also get the current orbit center.

Standard Draw 3D Reference 19ORBIT MODE is the default mode, in which dragging with the left mouse button orbits about asingle point. This is the origin by default, but can be changed. Can specify scalar or vector input.Can also get the current orbit center.All criptionx - component of orbit centery - component of orbit centerz - component of orbit centerorbit center, equivalent to 8x, y, z MethodssetOrbitCenter Hx, y, zLsetOrbitCenter HvLgetOrbitCenter HLReturn Type NamevoidvoidVector3DArgumentsPoints, Lines, and SurfacesBesides solid three-dimensional objects, you can also draw lower-dimensional shapes like points,lines, and polygons. Colors and thicknesses are still governed by pen settings. Methods for drawingsets of objects rather than individual ones are much more efficient. Every drawing function returns aShape object, which can be moved, rotated, and scaled dynamically using the methods of the Shapeclass.PointsDraws a single point or a set of points with the given coordinates. Drawing a set of points is muchmore efficient than drawing individual points, and you can still specify individual colors for eachpoint. For example, the first point is at (x[0], y[0], z[0]) with color colors[0].All ble@DColor@DNamexyzxyzcolorsDescriptionx - coordinatey - coordinatez - coordinateset of x - coordinatesset of y - coordinatesset of z - coordinatesset of colors that correspond to the set of pointsReturn ValueReturns the drawn Shape object, which can be further manipulated.Single Pointpoint Hx, y, zLReturn Type NameShapeArgumentsSet of PointsPrinted by Mathematicafor Students

20 Standard Draw 3D Referencepoints Hx, y, zLpoints Hx, y, z, colorsLReturn Type NameShapeShapeArgumentsLinesDraws a single line or a set of line with the given start and end coordinates. Drawing a set of lines ismuch more efficient than drawing individual lines, and you can still specify individual colors foreach line. For example, the first line is from (x[0], y[0], z[0]) to (x[1], y[1], z[1]), and the secondline is from (x[1], y[1], z[1]) to (x[2], y[2], z[2]). Vertex colors can be specified by the given array,and line colors are blends of its two vertex colors.All olorsDescriptionx - coordinate of the start pointy - coordinate of the start pointz - coordinate of the start pointx - coordinate of the end pointy - coordinate of the end pointz - coordinate of the end pointset of x - coordinates of the line verticesset of y - coordinates of the line verticesset of z - coordinates of the line verticesset of colors that correspond to the set of linesReturn ValueReturns the drawn Shape object, which can be further manipulated.Single Lineline Hx1, y1, z1, x2, y2, z2LReturn Type Name ArgumentsShapeSet of Lineslines Hx, y, zLlines Hx, y, z, colorsLReturn Type NameShapeShapeArgumentsPolygonsDraws a 2D polygon in 3D space with the given vertices. Vertices should be planar. Can specifyfilled or exyzDescriptionx - coordinates of each vertexy - coordinates of each vertexz - coordinates of each vertexPrinted by Mathematicafor Students

Standard Draw 3D Reference 21Return ValueReturns the drawn Shape object, which can be further manipulated.Filled Polygonpolygon Hx, y, zLReturn Type NameShapeArgumentsWireframe PolygonwirePolygon Hx, y, zLReturn Type NameShapeArgumentsTrianglesDraws a set of triangles which are defined by the given coordinates. Coordinates are provided in anN by 9 array, where N is the number of triangles to draw and points[i] {x1, y1, z1, x2, y2, z2, x3,y3, z3}. Can be used to create custom 3D meshes. Can specify filled or wireframe.ArgumentsTypeNameDescriptiondouble@D@D points set of nine vertex coordinates for N trianglesColor@Dcolors set of colors that correspond to the set of trianglesReturn ValueReturns the drawn Shape object, which can be further manipulated.Filled Trianglestriangles HpointsLtriangles Hpoints, colorsLReturn Type NameShapeShapeArgumentsWireframe TriangleswireTriangles HpointsLwireTriangles Hpoints, colorsLReturn Type NameShapeShapeArgumentsSaving and LoadingYou can save your current drawing window as an image file or a 3D scene. The 3D scene can beloaded later without having the original code that created it. You can also use the GUI toolbar menuof the drawing window or the keyboard shortcuts listed there.Image FileSaves the current drawing window to a file. The specified file must have a .png or .jpg extension!ArgumentsTypeNameDescriptionPrinted by Mathematicafor Students

22 Standard Draw 3D ReferenceString filename name of the file to save toMethodssave HfilenameLReturn Type Name Argumentsvoid3D SceneThere is experimental support for saving and loading a 3D scene as a file. When you save, thecurrent 3D scene in the drawing window is written to a file which can be loaded back in. Somecomputers have been found to not load properly. The recommended extension for identificationpurposes is .3d.ArgumentsTypeNameDescriptionString filename name of the file to save or loadMethodssaveScene3D HfilenameLloadScene3D HfilenameLReturn Type NamevoidvoidArgumentsLightsLight in the 3D scene is what controls the way they appear, and it is fully controllable. Light inStdDraw3D behaves similarly to actual light. At the initialization of each 3D scene,setDefaultLight() is called, which places two white directional lights in the scene - this is why asphere has two bright sides and a dark band in the middle. You can only see object colors that canbe reflected by the light color. Thus, white light makes any color visible, but if you only have redlight in the scene, you will only see the red component of object colors.Light UtilitiesThe default lighting consists of two white directional lights. If you want to set up custom lighting,then clear the existing lights with clearLight() and add your own.MethodssetDefaultLight HLclearLightHLReturn Type NamevoidvoidArgumentsAmbient LightAmbient light is light that is everywhere, regardless of position or orientation. If there is ambientlight, every object is lit up equally by it. Usually you want to keep ambient light very low, so pick adark color or a very transparent one.ArgumentsPrinted by Mathematic

Standard Draw 3D Complete Reference Manual Hayk Martirosyan Introduction Standard Draw 3D is a Java library with the express goal of making it simple to create three-dimensional models, simulations, and games. If you have not used StdDraw3D before, make