-
Notifications
You must be signed in to change notification settings - Fork 3
Shapes
Here is a full list of attributes for a box. All 3D objects have all of these attributes, other than arrow and curve:
pos (Position): the center of the box; default = vec(0,0,0). Takes a vector as an argument.
axis:The axis points in the direction of the length of the box, default = vec(1,0,0). Only the direction of the axis is meaningful, not its magnitude. The length of the box is size.x, not the magnitude of the axis. An object's axis and up attributes are always perpendicular to each other. Changing the direction of axis also changes the direction of up so that the two directions always remain at right angles to each other. Takes a vector as an argument.
size: The length, width, and height of the box; default = vec(1,1,1). Takes a vector as an arguement.
up: Which side of the box is "up". An object's axis and up attributes are always perpendicular to each other. Changing the direction of up also changes the direction of axis so that the two directions always remain at right angles to each other. Takes a vector as an argument.
color: Color of object. Takes a color as an argument.
texture: You can specify a texture to apply to the object's surface. Takes a Takes a texture as an argument.
opacity: Opacity of object, default = 1 (fully opaque); 0 is completely transparent. Takes a 1 or 0 as an arguement.
make trail: Creates a dissipating path following the object. There are 4 components.
make trail: Trail visibility. takes true or false as an argument. type determines the shape of the trail, takes "curve" or "points" as an argument.
type: Trail shape. Default is "curve", but can be "points".
retain: Retain=50, only the 50 most recently added points will be retained, takes a constant as an argument.
interval: If interval=10, a point is added to the trail only every 10th move of the object. If interval is 0, no trail is shown. If trail_type is "points", the default interval = 1; interval must have a nonzero value because the points need to be accurately spaced in order to look right. If trail_type is "curve" (the default), and no interval is specified, updates to the trail are made every time a new image is rendered, typically about 30 to 60 times a second. This usually looks fine. Takes a constant as an argument.
velocity: Determines velocity of object (first derivative of motion). Takes a vector as an argument.
acc (Acceleration): Determines acceleration of object (second derivative of motion). Takes a vector as an argument.
mass: Determines mass of object. Takes a constant as an argument.
charge: Determines charge of object. Takes a constant as an argument.
This produces a sphere centered at location (1,2,1) with diameter = 3. If you specify unequal values for the components of size, you get an ellipsoid.
Here is a full list of attributes for a sphere. All 3D objects have all of these attributes, other than arrow and curve:
pos (Position): the center of the sphere; default = vec(0,0,0). Takes a vector as an argument.
axis: The axis points in the direction of the length of the sphere, default = vec(1,0,0). Only the direction of the axis is meaningful, not its magnitude. The length of the sphere is size.x, not the magnitude of the axis. Takes a vector as an argument.
radius: The radius of the sphere (the distance from the center to the surface of the sphere). Takes a constant as an argument.
up: Which side of the box is "up". An object's axis and up attributes are always perpendicular to each other. Changing the direction of up also changes the direction of axis so that the two directions always remain at right angles to each other. Takes a vector as an argument.
color: Color of object. Takes a color as an argument.
texture: You can specify a texture to apply to the object's surface. Takes a Takes a texture as an argument.
opacity: Opacity of object, default = 1 (fully opaque); 0 is completely transparent. Takes a 1 or 0 as an arguement.
make trail: Creates a dissipating path following the object. There are 4 components.
make trail: Trail visibility. takes true or false as an argument. type determines the shape of the trail, takes "curve" or "points" as an argument.
type: Trail shape. Default is "curve", but can be "points".
retain: Retain=50, only the 50 most recently added points will be retained, takes a constant as an argument.
interval: If interval=10, a point is added to the trail only every 10th move of the object. If interval is 0, no trail is shown. If trail_type is "points", the default interval = 1; interval must have a nonzero value because the points need to be accurately spaced in order to look right. If trail_type is "curve" (the default), and no interval is specified, updates to the trail are made every time a new image is rendered, typically about 30 to 60 times a second. This usually looks fine. Takes a constant as an argument.
velocity: Determines velocity of object (first derivative of motion). Takes a vector as an argument.
acc (Acceleration): Determines acceleration of object (second derivative of motion). Takes a vector as an argument.
mass: Determines mass of object. Takes a constant as an argument.
charge: Determines charge of object. Takes a constant as an argument.
Here is a full list of attributes for an arrow. All 3D objects have all of these attributes, other than arrow and curve:
pos (Position): the center of the base of the tail; default = vec(0,0,0). Takes a vector as an argument.
axis: Due to its typical uses for quantitative displays of vector quantities, the arrow object differs from the other 3D objects. There is no size attribute; the lateral dimensions are determined by shaftwidth. The attribute axis is used to specify the direction of the arrow object. For example, pointer.axis = vec(3,4,0) yields an arrow pointing in the direction of vec(3,4,0). Takes a vector as an argument.
length: The length, width, and height of the box; default = vec(1,1,1). Takes a vector as an arguement.
shaftwidth By default, shaftwidth = 0.1*(length of arrow). Takes a constant as an argument.
headwidth By default, headwidth = 2*shaftwidth. Takes a constant as an argument.
headlength By default, headlength = 3*shaftwidth. Takes a constant as an argument.
up: Which side of the arrow is "up". Takes a vector as an argument.
color: Color of object. Takes a color as an argument.
texture: You can specify a texture to apply to the object's surface. Takes a Takes a texture as an argument.
opacity: Opacity of object, default = 1 (fully opaque); 0 is completely transparent. Takes a 1 or 0 as an arguement.
make trail: Creates a dissipating path following the object. There are 4 components.
make trail: Trail visibility. takes true or false as an argument. type determines the shape of the trail, takes "curve" or "points" as an argument.
type: Trail shape. Default is "curve", but can be "points".
retain: Retain=50, only the 50 most recently added points will be retained, takes a constant as an argument.
interval: If interval=10, a point is added to the trail only every 10th move of the object. If interval is 0, no trail is shown. If trail_type is "points", the default interval = 1; interval must have a nonzero value because the points need to be accurately spaced in order to look right. If trail_type is "curve" (the default), and no interval is specified, updates to the trail are made every time a new image is rendered, typically about 30 to 60 times a second. This usually looks fine. Takes a constant as an argument.
velocity: Determines velocity of object (first derivative of motion). Takes a vector as an argument.
acc (Acceleration): Determines acceleration of object (second derivative of motion). Takes a vector as an argument.
mass: Determines mass of object. Takes a constant as an argument.
charge: Determines charge of object. Takes a constant as an argument.
End vs center: The pos attribute for arrow, cone, cylinder, helix, and pyramid corresponds to one end of the object, whereas for a box, ring, or sphere it corresponds to the center of the object.
Studying this description of the cylinder object provides an overview of important aspects common to all of the GlowScript 3D objects, box, sphere, pyramid, etc. Additional details about how to orient an object using "axis" and "up" are found in the description of the box object.
Here is an example of how to make a cylinder, naming it "rod" for future reference:
rod = cylinder() rod.pos = vec(0,1,2) rod.axis = vec(1,0,0) rod.size = vec(5,1,1)
Attributes: The properties pos (position), axis, and size are called "attributes" of the object. The function "vec" creates a vector with (x,y,z) components.
cylinder Alternatively, you can specify the initial values of the attributes when creating the cylinder::
rod = cylinder( pos=vec(0,2,1), axis=vec(1,0,0), size=vec(5,1,1) )
pos (Position): the center of the sphere; default = vec(0,0,0). Takes a vector as an argument.
axis: The axis points in the direction of the length of the sphere, default = vec(1,0,0). Only the direction of the axis is meaningful, not its magnitude. The length of the sphere is size.x, not the magnitude of the axis. Takes a vector as an argument.
radius: The radius of the sphere (the distance from the center to the surface of the sphere). Takes a constant as an argument.
up: Which side of the box is "up". An object's axis and up attributes are always perpendicular to each other. Changing the direction of up also changes the direction of axis so that the two directions always remain at right angles to each other. Takes a vector as an argument.
color: Color of object. Takes a color as an argument.
texture: You can specify a texture to apply to the object's surface. Takes a Takes a texture as an argument.
opacity: Opacity of object, default = 1 (fully opaque); 0 is completely transparent. Takes a 1 or 0 as an arguement.
make trail: Creates a dissipating path following the object. There are 4 components.
make trail: Trail visibility. takes true or false as an argument. type determines the shape of the trail, takes "curve" or "points" as an argument.
type: Trail shape. Default is "curve", but can be "points".
retain: Retain=50, only the 50 most recently added points will be retained, takes a constant as an argument.
interval: If interval=10, a point is added to the trail only every 10th move of the object. If interval is 0, no trail is shown. If trail_type is "points", the default interval = 1; interval must have a nonzero value because the points need to be accurately spaced in order to look right. If trail_type is "curve" (the default), and no interval is specified, updates to the trail are made every time a new image is rendered, typically about 30 to 60 times a second. This usually looks fine. Takes a constant as an argument.
velocity: Determines velocity of object (first derivative of motion). Takes a vector as an argument.
acc (Acceleration): Determines acceleration of object (second derivative of motion). Takes a vector as an argument.
mass: Determines mass of object. Takes a constant as an argument.
charge: Determines charge of object. Takes a constant as an argument.
The following statement creates a ring centered at location vec(3,0,1), with its axis pointing in the vec(0,1,0) direction, and with a thickness in that direction of 0.2 and a diameter of 1:
ring( pos=vec(3,0,1), axis=vec(0,1,0), size=vec(0.2,1,1) )
Here is a full list of attributes for a ring. All 3D objects have all of these attributes, other than arrow (which has axis_and_length instead of axis):
pos Position: the center of one end of the ring; default = vec(0,0,0).
size The length, width, and height of the ring; default = vec(0.1,1,1), where size.x is the thickness of the ring.
axis The axis points in the direction of the length of the ring, default = vec(1,0,0). Only the direction of the axis is meaningful, not its magnitude. The length of the ring is size.x, not the magnitude of the axis.
color Color of object, as a red-green-blue (RGB) triple: vec(1,0,0) is the same as color.red, default = vec(1,1,1), which is color.white.
up Which side of the ring is "up".
visible If False, object is not displayed; e.g. myring.visible = False Use myring.visible = True to make the object visible again.
End vs center: The pos attribute for arrow, cone, cylinder, helix, and pyramid corresponds to one end of the object, whereas for a box, ring, or sphere it corresponds to the center of the object.
To display a trail or an arrow along the path of a moving object, see Attach a trail or arrow.
No texture or opacity: Currently rings, like curve, cannot be transparent, it is not possible to apply a texture, and it cannot be part of a compound object.
The following statement will display a helix that is parallel to the x axis (the default axis direction), with length 5 and diameter 1:
var spring = helix( pos=vec(0,2,1), size=vec(5,1,1) )
pos (Position): the center of the sphere; default = vec(0,0,0). Takes a vector as an argument.
axis: The axis points in the direction of the length of the sphere, default = vec(1,0,0). Only the direction of the axis is meaningful, not its magnitude. The length of the sphere is size.x, not the magnitude of the axis. Takes a vector as an argument.
radius: The radius of the sphere (the distance from the center to the surface of the sphere). Takes a constant as an argument.
up: Which side of the box is "up". An object's axis and up attributes are always perpendicular to each other. Changing the direction of up also changes the direction of axis so that the two directions always remain at right angles to each other. Takes a vector as an argument.
color: Color of object. Takes a color as an argument.
texture: You can specify a texture to apply to the object's surface. Takes a Takes a texture as an argument.
opacity: Opacity of object, default = 1 (fully opaque); 0 is completely transparent. Takes a 1 or 0 as an arguement.
make trail: Creates a dissipating path following the object. There are 4 components.
make trail: Trail visibility. takes true or false as an argument. type determines the shape of the trail, takes "curve" or "points" as an argument.
type: Trail shape. Default is "curve", but can be "points".
retain: Retain=50, only the 50 most recently added points will be retained, takes a constant as an argument.
interval: If interval=10, a point is added to the trail only every 10th move of the object. If interval is 0, no trail is shown. If trail_type is "points", the default interval = 1; interval must have a nonzero value because the points need to be accurately spaced in order to look right. If trail_type is "curve" (the default), and no interval is specified, updates to the trail are made every time a new image is rendered, typically about 30 to 60 times a second. This usually looks fine. Takes a constant as an argument.
velocity: Determines velocity of object (first derivative of motion). Takes a vector as an argument.
acc (Acceleration): Determines acceleration of object (second derivative of motion). Takes a vector as an argument.
mass: Determines mass of object. Takes a constant as an argument.
charge: Determines charge of object. Takes a constant as an argument. ``