リファレンス › Physics — 97 個のコマンド


environment

physics

入力: modelname (word) | [modelname mode] (list)
出力: none

Creates a static physics collision environment from the given model. The model becomes a physical barrier that other physics-enabled turtles will collide with. The optional mode parameter specifies the collision mesh type: "convex (default) for convex hull collision or "trimesh for triangle mesh collision. Triangle mesh is more accurate for complex shapes but more computationally expensive. See physical, noaffix

environment "terrain
environment ["building "trimesh]

lockaxis

physics

入力: axis (word)
出力: none

Causes the physics engine to lock the calling turtle to the specified axis – it cannot move the turtle along that axis, making it one dimensional. The parameter can be "x or "y. nolockaxis turns it off. See lockaxisp.

lockaxis "x

noforces

physics

入力: none
出力: none

Removes all global forces affecting physical and elastic turtles. See forces, setforces, nomyforces

noforces

nomyforces

physics

入力: none
出力: none

Removes all per-turtle forces on the calling turtle. See myforces, setmyforces, noforces

nomyforces

nolockaxis

physics

入力: word ("x or "y)
出力: none

Disables the specified lockaxis.

nolockaxis "x

addvelocity

physics

入力: heading | turtle-units / second
出力: none

Adds velocity to the calling turtle. See velocity

addvelocity 90 20

advancephysics

physics

入力: number
出力: none

If pausephysics is enabled, advances the physics engine by the given number of seconds. See pausephysics

advancephysics 1/60

affix

physics

入力: none
出力: none

Causes the turtle's position to be unchangeable by the physics engine. See noaffix, affixp

affix

angularfriction

physics

入力: none
出力: number

Returns the angular friction, or the percentage the turtle's angular velocity (torque) is diminished per second. See setangularfriction

show angularfriction
5

anglethreshold

physics

入力: none
出力: degrees (number)

Returns the current angle threshold, or the number of degrees the representation of a turtle in the physics engine must turn before it is reflected in the graphical representation of the turtle. This is a global setting that affects all turtles.

show anglethreshold

angularvelocity

physics

入力: none
出力: number

Returns the degrees per second of angular velocity (rotation) in the calling turtle. Note that changing the turtle's heading zeroes its angularvelocity. See setangularvelocity, twist, stabilize

show angularvelocity

angularvelocityvector

physics

入力: none
出力: list

Returns the 3D angular velocity vector of the calling turtle in radians per second. This is the full rotation axis and speed as a vector [x y z]. Requires 3D physics mode. See setangularvelocityvector, angularvelocity

show angularvelocityvector

appendblockmap

physics

入力: none
出力: none

Adds to the blockmap. The appending turtle does not need to be the turtle that created the existing blockmap. endblockmap ceases adding to the blockmap. See beginblockmap

appendblockmap

beginblockmap

physics

入力: none
出力: none

Outlines of shapes created by the calling turtle after beginblockmap is declared are added to the 'blockmap', a shadow representation used by the physics engine to detect collisions with defined areas in the environment. 'Elastic' turtles will deflect from the blockmap, other turtles may be blocked if they declare 'blockmap'; it can also be detected using blocktestp. endblockmap ceases adding shapes to the blockmap

Declaring beginblockmap again erases the existing blockmap. To add more to the blockmap, use appendblockmap
Parts of the blockmap take on the current elasticity of the turtle who added them. This enables the creation of an environment with areas of varied elasticity. See endblockmap, blockmap, blocktestp
beginblockmap

blockmap

physics

入力: none
出力: none

Causes the turtle to be 'blocked' by the blockmap, regardless of physics mode. To work, the turtle must have a model, and that model must be shown. A 'hitbox' of the model is created when blockmap is called. See noblockmap, which turns it off

blockmap

blockmapsubtract

physics

入力: none
出力: none

An opening tag (with companion closing tag endblockmapsubtract) that attempts to remove the shapes created within it from the blockmap. However, it currently cannot remove shapes that lie entirely inside other shapes, it can only modify those shapes' edges. See endblockmapsubtract, blockmap

blockmapsubtract

blockmissiles

physics

入力: class
出力: list

Returns a list of missiles of the given class blocked by the blockmap since last read. See blockmissilep

show blockmissiles

brake

physics

入力: number
出力: none

Causes the velocity of the calling turtle to diminish by the specified percentage (100 = full stop). See thrust

brake 50

buildblockmap

physics

入力: none
出力: none

Build (or rebuild) the blockmap based on the calling turtle's track. If you want to build the blockmap continually or incrementally use beginblockmap instead. See blockmap

buildblockmap

clearblockmap

physics

入力: none
出力: none

Clears the blockmap. See beginblockmap

clearblockmap

collidedwith

physics

入力: none
出力: list

Returns a list of turtles the physical calling turtle has intersected with since last read.

show collidedwith

complexmodel

physics

入力: none
出力: none

Generates multiple linked physics bodies based on the different elements within the turtle's model. This allows for concave physical models such as crescents or propellers. For simpler models such as spheres or squares, simplemodel is more appropriate (and less resource-intensive). See simplemodel

complexmodel

deferphysics

physics

入力: none
出力: none

Suspends (defers) participation of the calling turtle in the physics engine without affecting its physical state – if it's moving, you can 'pause' it using deferphysics, and then call nodeferphysics to resume its movement at a later point. See nodeferphysics, and pausephysics, which does this globally (for all turtles)

deferphysics

deflectedby

physics

入力: none
出力: list

Returns a list of turtles (if any) that have deflected (or been deflected by) the calling turtle since deflectedby was last read. See deflectedp

show deflectedby

deflectedobjectp

physics

入力: name (word) OR class names (list)
出力: boolean

Returns true if the calling turtle has deflected (or been deflected by) the given object or an object of the given class(es) since last read. If given a word, it is treated as an object name with an optional class argument. If given a list, it is treated as class names to check. See deflectedobjects

show deflectedobjectp "myobject
show deflectedobjectp [enemy]

deflectedobjects

physics

入力: class names (list or word)
出力: list

Returns a list of objects of the given class(es) that have deflected (or been deflected by) the calling turtle since last read. See deflectedobjectp

show deflectedobjects [enemy]
show deflectedobjects "bullet

deletescene

physics

入力: name (word)
出力: none

Deletes a scene. Members of the scene return to the 'home' scene. See newscene, selectscene

deletescene "scene

elastic

physics

入力: none
出力: none

Makes a turtle 'elastic', which is a participant in the physics engine that deflects off of other elastic and mechanical turtles, objects and the blockmap. Elastic turtles have a 'hitbox' generated based on their model which identifies their bounds. Hidden elastic turtles are still subject to forces / gravity / velocity but are otherwise insubstantial – they do not deflect off of other turtles, objects or the blockmap, and nor do other turtles or objects bounce off of them, as they have no 'hitbox'. Note that if they are declared elastic before shown, they will not separate from overlapping elastic objects, and as such elastic should be declared after they are shown. See physical, mechanical, phantom, static

elastic

elasticity

physics

入力: none
出力: number

Returns the calling turtle's 'elasticity', or the percentage of force that is transferred from the turtle to other turtles, objects or the blockmap. These items may themselves, depending on their elasticity, transfer force back to the turtle, causing it to repel or 'bounce'. See setelasticity

show elasticity

endblockmap

physics

入力: none
出力: none

'Closes' the blockmap. Shapes subsequently created are not added to the blockmap. To add to the blockmap later, use appendblockmap. See beginblockmap

endblockmap

endblockmapsubtract

physics

入力: none
出力: none

An ending tag (with companion opening tag blockmapsubtract) that attempts to remove the shapes created within it from the blockmap. However, it currently cannot remove shapes that lie entirely inside other shapes, it can only modify those shapes' edges. See endblockmapsubtract, endblockmap

endblockmapsubtract

forces

physics

入力: none
出力: [[[vector] OR heading | turtle-units / second]] (list of lists)

Returns the current list of global 'forces', or directional effects on physical and elastic turtles. See setforces, setmyforces, myforces

show forces

friction

physics

入力: none
出力: number

Returns the percentage (per second) that the turtle's velocity is diminished by friction. See setfriction

show friction

gravity

physics

入力: none
出力: none

Causes the mass of the calling turtle to affect other turtles and be affected by gravitypoints and/or the mass of other turtles. This is off by default. A turtle must be physical to be affected by gravity. See nogravity, gravitypoints, setmass

gravity

gravitypoints

physics

入力: none
出力: [[[position] mass][[position] mass]…] (list)

Returns the current list of gravity points (global). See setgravitypoints

show gravitypoints

hitby

physics

入力: none
出力: list

Returns a list of turtle(s) currently contacting (touching) the calling turtle. See hitp, which detects collisions. For a similar list of turtles that have previously contacted the calling turtle, see deflectedby, collidedwith.

show hitby

hitmissiles

physics

入力: class OR [class1 class2…]
出力: list

Returns a list of missiles of the given class(es) that have contacted the calling turtle since last read. If an empty list is provided, returns missiles of all classes. See hitmissilep, which detects contacts (collisions).

show hitmissiles

hitobjects

physics

入力: class
出力: list

Returns a list of objects of the given class collided with by the calling turtle since last read. See hitobjectp, a boolean which detects collisions.

show hitobjects

hitpos

physics

入力: position
出力: list

Returns the names of turtles other than the calling turtle whose physics bodies (hulls) overlap the given location. See hittestp, which returns true if there are other turtles present at that location.

show hitpos [30 60]

hittest

physics

入力: heading distance
出力: list

Returns the names of turtles other than the calling turtle whose physics bodies (hulls) overlap the given location. See hittestp, which returns true if there are other turtles present at that location.

show hittest 90 20

hull

physics

入力: none
出力: list

Returns the dimensions of the turtles hitbox, or hull.

show hull

listscenes

physics

入力: none
出力: none

Prints out a list of the current scenes. See selectscene, newscene

listscenes

maxvelocity

physics

入力: none
出力: number

Returns the turtles 'maxvelocity' or the maximum turtle-units the physics engine may nove the turtle per second. See setmaxvelocity

show maxvelocity

mechanical

physics

入力: none
出力: none

Makes a turtle 'mechanical'. Mechanical turtles are represented in the physics engine but are not affected by forces such as elasticity, velocity or torque. They do not themselves move in response to collisions or forces, but do act to block or impart force on those turtles that collide with them. See elastic, physical, phantom

mechanical

mass

physics

入力: none
出力: number

Returns the mass of the calling turtle in kilograms (default 10kg). See setmass

show mass

maxangularvelocity

physics

入力: none
出力: number

Returns the turtle's maximum angular (rotational) velocity. See setmaxangularvelocity to set it

show maxangularvelocity

myforces

physics

入力: none
出力: [[[vector] OR heading | turtle-units / second]] (list of lists)

Returns the current list of forces affecting the calling turtle specifically. See setmyforces, forces

show myforces

newscene

physics

入力: name (word)
出力: none

Creates a scene of the given name. Scenes are distinct physical spaces. See selectscene (which selects it).

newscene "scene

noaffix

physics

入力: none
出力: none

Removes affix from the calling turtle. See affix

noaffix

noblockmap

physics

入力: none
出力: none

Disables 'blocking' of the calling turtle by the blockmap. See blockmap, beginblockmap

noblockmap

nodeferphysics

physics

入力: none
出力: none

Resumes participation in the physics engine by the calling turtle, which was suspended by deferphysics. See deferphysics

nodeferphysics

nogravity

physics

入力: none
出力: none

Disables gravity on the calling turtle. See gravity, gravitypoints, mass

nogravity

noreorient

physics

入力: none
出力: none

Disables reorient. See reorient.

noreorient

notorque

physics

入力: none
出力: none

Disables torque (rotational velocity) on the calling turtle. See torque

notorque

pausephysics

physics

入力: none
出力: none

Suspends the physics engine, and all its effects on turtles, objects and missiles. This includes blockmap collisions. See resumephysics

pausephysics

phantom

physics

入力: none
出力: none

Makes a physical turtle ordinary. 'phantom' is the default turtle state, it does not have a representation in the physics engine. See elastic, physical, mechanical

phantom

physical

physics

入力: none
出力: none

Makes a turtle 'physical'. Physical turtles have a representation in the physics engine and can be impacted by forces and gravity (if enabled) but are NOT deflected nor exert force on other turtles (eg not elastic). Intersections with other turtles can be detected with collidedp, collidedwith. To be blocked by the blockmap, 'blockmap' must be declared. See elastic, phantom, mechanical

physical

physicsinterval

physics

入力: none
出力: number

Returns the current physics 'interval', the time between internal updates of the physics model. See setphysicsinterval, which sets it.

show physicsinterval

physicsmode

physics

入力: none
出力: word

Returns the current physics engine mode, either "2d (Chipmunk 2D physics) or "3d (AmmoJS 3D physics). See setphysicsmode

show physicsmode

physicsspeed

physics

入力: none
出力: number

Returns the current physics speed, see setphysicsspeed

show physicsspeed

positionthreshold

physics

入力: none
出力: number

Returns the position threshold, or the distance the physics representation of a turtle must move before it is updated in its graphical representation. See setpositionthreshold

show positionthreshold

reorient

physics

入力: none
出力: none

Causes the turtle to face the direction of its current velocity, eg the velocityheading. noreorient turns it off.

reorient

resumephysics

physics

入力: none
出力: none

Resumes processing of the physics engine. See pausephysics

resumephysics

scene

physics

入力: none
出力: word

Returns the turtle's current 'scene' or physical space. The default scene is 'home'. Members of the same scene interact physically with each other – members do not interact with members from other scenes. Each scene also has its own blockmap – this is useful for multi-layered constructions. See selectscene, newscene, deletescene, scenes.

show scene

scenes

physics

入力: none
出力: list

Returns a list of the currently active 'scenes', or physical spaces. The default scene is 'home'. See listscenes, scenes, selectscene

show scenes

selectscene

physics

入力: word (name)
出力: none

Selects the turtle's current 'scene' or physical space from those available. The default scene is 'home'. New scenes can be created with newscene. Members of the same scene interact physically with each other – members do not interact with members from other scenes. Each scene also has its own blockmap – this is useful for multi-layered constructions. See newscene, deletescene, scenes.

selectscene "city

setangularfriction

physics

入力: number
出力: none

Sets the angular friction, or the percentage the turtle's angular velocity (torque) is diminished per second. See sngularfriction

setangularfriction 5

setanglethreshold

physics

入力: none
出力: degrees (number)

Sets the threshold at which angular changes in the physics models are reflected in their graphical counterparts. The physics model must turn at least the given number of degrees before the graphical model turns. This helps improve performance. This is a global setting that affects all turtles using the physics engine. See setpositionthreshold, which does similar with position

setanglethreshold 10

setangularvelocity

physics

入力: number
出力: none

Sets the angular velocity of the calling turtle, or the rate of rotation, in degrees per second. If the value provided is negative, the turtle spins counterclockwise. See angularvelocity, torque, twist and stabilize

setangularvelocity 90

setangularvelocityvector

physics

入力: [vector]
出力: none

Sets the direction of the calling turtle's angular velocity while preserving its current rotation speed. The vector specifies the new axis of rotation. Requires 3D physics mode. See angularvelocityvector, setangularvelocity

setangularvelocityvector [0 0 1]

setelasticity

physics

入力: number
出力: none

Sets the calling turtle's 'elasticity', or the percent of force that is transferred from the turtle to other turtles, objects or the blockmap. These items may themselves, depending on their elasticity, transfer force back to the turtle, causing it to repel or 'bounce'. See elasticity

setelasticity 100

setforces

physics

入力: [[[vector] OR heading | turtle-units / second]] (list of lists)
出力: none

Sets global 'forces', or constant directional effects on physical and elastic turtles. In contrast to gravitypoints, which attract to specific locations, forces drag turtles in a specific direction regardless of location. This can be useful for platform games that need downward 'gravity', for example.

Forces are affected by mass inversely -- the higher the mass of a turtle, missile or object the longer the effect takes to reach maximum influence. See setnass
Note that setforces takes a list of lists, so that multiple forces can be set at one time. See forces, setmyforces (which work on individual turtles) and myforces
Also note that turtles / objects closely aligned on the boundaries of their physics models may be forced through each other if forces are set sufficiently high (allow a bit of space!)
setforces [[180 50]]

setfriction

physics

入力: number
出力: none

Sets the friction, or the percentage the turtle's velocity is diminished per second. See friction

setfriction 5

setgravitypoints

physics

入力: [[[position] mass][[position] mass]…] (list of lists)
出力: none

Sets the 'gravity points', a list of locations in turtle space that have associated mass, which affects turtles with gravity enabled. Note that these can be set negative, to repulse gravity turtles. See gravity, gravitypoints

setgravitypoints {{position 10^15}}

setmass

physics

入力: number
出力: none

Sets the mass of the calling turtle in kilograms (kg). This is used with elasticity, gravity and forces to determine their affects on the turtle, and its affect on others. The default mass of a turtle is 10. See gravity, setforces, setgravitypoints

setmass 500

setmaxangularvelocity

physics

入力: number
出力: none

Sets the maximum angular (rotational) velocity of the calling turtle, in degrees / second. This is the fastest the turtle will rotate. See maxangularvelocity

setmaxangularvelocity 90

setmaxvelocity

physics

入力: number
出力: none

Sets the maximum velocity of the calling turtle, in turtle-units / second. This is the fastest the turtle can be moved by the physics engine. See maxvelocity

setmaxvelocity 100

setmyforces

physics

入力: [[[vector] OR heading | turtle-units / second]] (list of lists)
出力: none

Sets local (or turtle-specific) forces, or constant directional effects on physical and elastic turtles. In contrast to gravitypoints, which attract to specific locations, forces drag turtles in a specific direction regardless of location. This can be useful for platform games that need downward 'gravity', for example. This command only works on the calling turtle, for global forces, see setforces

setmyforces [[90 50]]

setphysicsinterval

physics

入力: number
出力: none

Sets the physics interval, or the time between updates of the internal physics model. The lower the value, the higher the accuracy. Note that increasing this value may cause collision detection to work imprecisely (balls may travel through walls, for example, in the 'time' between updates). Defaults to 1/60th of a second. See physicsinterval, which returns the current value

setphysicsinterval 1/20

setphysicsmode

physics

入力: "2d | "3d
出力: none

Sets the physics engine mode. Use "2d for Chipmunk 2D physics or "3d for AmmoJS 3D physics. The physics mode determines which physics engine is used for collision detection and physical simulation. See physicsmode

setphysicsmode "3d

setphysicsspeed

physics

入力: number
出力: none

Allows the user to specify a fixed time increment to apply to the physics engine during each update, rather than the default "delta-t" of the elapsed real-world time (0). This is useful for using the physics engine for drawing operations to ensure accuracy. See physicsspeed

setphysicsspeed 1

setpositionthreshold

physics

入力: number
出力: none

Sets the 'threshold' (in turtle-units) at which the physics engine updates the turtle positions in the environment. The internal physics model of the turtle must move the given number of turtle-units in order for its graphical representation to be updated. This is a global setting that affects all turtles. This improves performance at the expense of frame rate. See positionthreshold

setpositionthreshold 5

setsurfacefriction

physics

入力: number
出力: none

Sets the current surface friction value, which indicates how much velocity is lost as a percentage over time when the calling turtle's physics body contacts another. Note that missiles and objects inherit surfacefriction (and other friction values) from their parent turtle. See surfacefriction

seturfacefriction 20

setvelocity

physics

入力: number
出力: none

Sets the calling turtle's velocity, using the current velocityheading, or the turtle's forward direction if no current velocityheading exists. See velocityheading, velocity, thrust

setvelocity 50

setvelocityheading

physics

入力: heading
出力: none

Sets the calling turtle's velocity heading, that is, the direction it is currently being moved by the physics engine. If the turtle is not moving, the set value will be used by setvelocity, or overwritten by thrust.

setvelocityheading 180

simplemodel

physics

入力: none
出力: none

Generates a simple single physics body for the turtle model, tracing a convex shape around all of the elements in the model. For the ability to have concave turtle models, declare complexmodel. See complexmodel

simplemodel

stabilize

physics

入力: number (percentage)
出力: none

Decreases the angularvelocity of a turtle by the given number, a percentage. So, stabilize 50 will cut the angularvelocity in half. See setangularvelocity, torque, brake (which does similar with velocity)

stabilize 50

static

physics

入力: none
出力: none

static is a physical turtle type for turtles that are not expected to move. They are the lowest maintenance for the physics engine generally but are the most expensive in terms of resources to move. See mechanical, elastic, physical

static

surfacefriction

physics

入力: none
出力: number

Returns the current surface friction value, which indicates how much velocity is lost as a percentage over time when the calling turtle's physics body contacts another. See setsurfacefriction

show surfacefriction

thrust

physics

入力: number (turtle-units / second)
出力: none

Adds velocity to the turtle in the current forward direction. Will make turtle 'elastic' if not currently a physical turtle (phantom). See addvelocity, brake

thrust 100

torque

physics

入力: none
出力: none

Enables 'torque' or angularvelocity to be modified on the calling turtle when it collides with other turtles, objects, missiles or the blockmap. See notorque, which turns it off.

torque

twist

physics

入力: deg / second (number)
出力: none

Increases angular velocity by the given amount. Use negative to increase it counterclockwise. Will make turtle 'elastic' if not already a physical turtle. See stabilize, which slows / stops it.


velocity

physics

入力: none
出力: number (turtle-units / second)

Returns the current velocity of the calling turtle. Note that calling setpos(ition) on a moving turtle zeroes its velocity. See addvelocity, thrust

show velocity

velocityheading

physics

入力: none
出力: degrees

Returns the current heading (direction) the calling turtle is being moved in by its velocity.

show velocityheading

velocityorientation

physics

入力: none
出力: list

Returns the orientation [heading pitch roll] that corresponds to the turtle's velocity direction. Calculates by transforming standard home vectors (viewDir [0 1 0], upDir [0 0 1], rightDir [1 0 0]) using the rotation from home viewDir to velocity direction, then extracting Euler angles.

show velocityorientation
[45 30 0]

velocityvectors

physics

入力: none
出力: list

Returns the transformed orientation vectors [[viewDir] [upDir] [rightDir]] based on the turtle's velocity direction. Transforms standard home vectors (viewDir [0 1 0], upDir [0 0 1], rightDir [1 0 0]) using the rotation from home viewDir to velocity direction.

show velocityvectors
[[0 1 0] [0 0 1] [1 0 0]]

updatephysics

physics

入力: none
出力: none

Forces a synchronization of a turtle's state with that of its body inside of the physics engine. Useful when positionthreshold is set relatively high, to update the turtle's position when colliding with other turtles, for example. See setpositionthreshold

updatephysics