Different shapes of pentagon12/15/2023 Shape=shapes.rectangle(width=10, height=3)) Here is an example:Įxtrusion(path=paths.rectangle(width=50, height=30), Just as the shapes library provides a convenient way to create 2D shapes to extrude, the paths library provides a convenient way to create 3D paths for the extrusion object. Rt = shapes.rectangle(pos=, width=10, height=6) In the following case the center of the rectangle will be 2 to the right and 1 above the path: You can displace the rectangular shape away from the extrusion path. In the examples discussed above, the center of the rectangle will be placed at the location of the extrusion path. If there are N holes in a shape, the first list in the shape is always the outer contour, and the next N lists represent the N holes. The first list describes the outer contour, and the next list describes the inner contour. Here is what rt is in this case of the rectangle with a hole: If the thickness parameter is not used, or if it is equal to zero, then there is no hole, and a solid rectangle is obtained. The resultant shape is the area covered between these two contours. Therefore there are two rectangular contours: One is the original rectangle of size 10 x 6 (the outer contour), and the second one is the hole of size 8.8 x 4.8 (0.1 times the short side of 6 gives a distance between the inner and outer contours of 0.6). This results in a rectangle with a rectangular hole. This defines a "rectangular frame" with a size 10 x 6, and a thickness of 0.1 times the shortest side of the rectangle, the height in this case. It is possible to define hollow rectangles – a rectangle with a rectangular hole, by using the thickness parameter: Rt = shapes.rectangle(width=10, height=6, xscale=2, yscale=0.5)Īll the previous definitions created solid rectangles covering the whole area defined by the width and the height of the rectangle. Width and height of a rectangle can be scaled independently by using xscale, yscale parameters: Rt = shapes.rectangle(width=10, height=6, scale=2)Įffectively creates a rectangle of size 20 x 12. The rectangle or its sides can be scaled by using the scale parameter: Rt = shapes.rectangle(width=10, height=6, A roundness of 0.1 is often a good choice.Īn inverted rounding (called a chamfer) can be obtained by setting the invert parameter as True, together with the roundness parameter. The radius of this arc is calculated by multiplying the roundness parameter by the shortest side of the rectangle, the height in this case. This creates a rectangle with its corners replaced by a circular arc of radius 0.6. Rt = shapes.rectangle(width=10, height=6, roundness=0.1) A negative angle rotates the figure clockwise.Ī rounded rectangle (a rectangle whose corners are rounded) can be obtained by using the roundness parameter: This produces a rectangle rotated counterclockwise pi/6 radians (30 degrees) around the path. Rt = shapes.rectangle(width=10, height=6, rotate=pi/6) The shape is shown in gray on the default black canvas background.Ī rotated rectangle can be obtained like this: The shape can be visualized in VPython by executing the following statement, which extrudes the rectangular shape into the screen, along the line from vec(0,0,0) to vec(0,0,-0.1):Įxtrusion(path=, If you print rt you will see this list of 2D coordinates, starting at the lower right and continuing counterclockwise, end at the starting location: If the height value is omitted the shape is a square with its sides equal to the given width. Rt = shapes.rectangle(width=10, height=6)Ĭreates a list of 2D x-y coordinates of the corners of a rectangle of width=10 and height=6. The paths library is similar but provides lists of 3D points along which the 2D shape is extruded.Ĭhoose one of the shapes that are available in these libraries:īe sure to read about rectangle, which explains features common to all of these objects (rotate, scale, xscale, yscale, roundness, thickness, and invert). In the shape shown above, a circular region has been removed from a star. The shapes library helps in creating complex 2D shapes by creating and combining basic geometric shapes. The shapes and paths libraries are mainly used together with the 3D extrusion object.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |