- All Implemented Interfaces:
Graph.Graphic
,NamedObjectOps
- Direct Known Subclasses:
GraphView
-
Constructor Summary
ConstructorsConstructorDescriptionDirectedObject2D
(Animation2D animation, String name, boolean intern) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Test if the angleRelative flag was set when the current path was set.boolean
Determine if this named object can be deleted.void
Clear the path.protected Object
clone()
Creates and returns a copy of this object.protected boolean
Return the default value of the angle-relative flag.final boolean
delete()
Delete an object.final boolean
Determine if an object is being deleted.double
Get the current angular velocity.double
getDistance
(double u1, double u2) Get the distance traversed on a subpath.double
Get the initial time at which a path traversal will start.protected double
Get the distance along the path at the start of a path traversal at the time specified in the last call to update.protected double
Get the path parameter for the start of a path traversal.double
Get the maximum value of the path parameter.final String
getName()
Get an object's name.protected Simulation
Get the object namer for a named object.double
Get the path acceleration.double
Get the path angle.double
getPathDxDu
(double u) Get the derivative of the x coordinate for a point along a path with respect to the path parameter.double
getPathDyDu
(double u) Get the derivative of the y coordinate for a point along a path with respect to the path parameter.double
Get the inversion limit that will be used for splines that are created by paths in order to determine the path distance given the path parameter and vice versa.double
Get the length of the path.double
getPathLength
(double u1, double u2) Get the length of the path parameter between an initial and final value of the path parameter.double
Get the path velocity.protected double
getPathX
(double u) Get the x coordinate for a point along a path.double
getPathY
(double u) Get the y coordinate for a point along a path.protected double
getS()
Get the current distance along the path at the time specified in the last call to update.double
getS
(double u) Get the current distance along the path from its start.protected double
getU()
Get the path parameter at the time specified in the last call to update.double
getU
(double s) Get the path parameter for a specific distance along the pathprotected double
Get the time used by the last call to update.boolean
hasPath()
Determine if this object has a path to follow.boolean
Determine if the path is closed.final boolean
Determine if an object has been deleted.boolean
Determine if an object is interned in a object namer's tables.boolean
Determine if the path exists.void
printConfiguration
(String iPrefix, String prefix, boolean printName, PrintWriter out) Print this simulation object's configuration.void
printState
(String iPrefix, String prefix, boolean printName, PrintWriter out) Print this simulation object's state.void
setAngle
(double angle) Set an object's angle.void
Set the function giving the angle of an object as a function of simulation time.void
Set the simulation function giving the angle of an object as a simulation function of simulation time.void
setAngleRelative
(boolean relative) Set whether or not the angle is relative to the current path.void
setAngularAcceleration
(double angularAcceleration) Set the angular acceleration.void
setAngularVelocity
(double angularVelocity) Set the angular velocity.void
Set the function giving the distance along the path as a function of time, setting the function at a specific simulation time.void
Set the simulation function giving the distance along the path as a function of time, setting the function at a specific simulation time.final void
setPath
(AnimationPath2D objectPath, boolean angleRelative, double time0) Set the path, using an AnimationPath2D object to specify the path and specifying the angle-relative flag.final void
setPath
(AnimationPath2D objectPath, double time0) Set the path, specified by an instance of AnimationPath2D.final void
setPath
(AnimationPath2D objectPath, double angle, boolean angleRelative, double time0) Set the path, using an AnimationPath2D object to specify the path and specifying both the angle and the angle-relative flag.final void
setPath
(AnimationPath2D objectPath, double u0, double angle, boolean angleRelative, double time0) Set a path, specified by an instance of AnimationPath2D and specifying an initial path parameter and angle for the object to follow.final void
setPath
(BasicSplinePath2D path, boolean angleRelative, double time0) Set the path, specifying the angle-relative flag.final void
setPath
(BasicSplinePath2D path, double time0) Set the path.final void
setPath
(BasicSplinePath2D path, double angle, boolean angleRelative, double time0) Set the path, specifying both the initial angle and the angle-relative flag.final void
setPath
(BasicSplinePath2D path, double u0, double angle, boolean angleRelative, double time0) Set a path for this object to follow, specifying an initial path parameter and angle.void
setPathAcceleration
(double pathAccel) Set the acceleration along the path.void
setPathAngle
(double angle) Set angle to use when traversing the current path.void
Set the function giving the angle of an object as a function of time measured from the point at which the traversal of a path begins.void
Set the simulation function giving the angle of an object as a function of time measured from the point at which the traversal of a path begins.void
setPathAngularAcceleration
(double pathAngularAccel) Set the angular acceleration along the path WhenangleIsRelative()
returns true, the angular acceleration refers to the change in angle relative to the tangent at the current location along a path.void
setPathAngularVelocity
(double pathAngularVelocity) Set the angular velocity along the path.protected void
setPathImplementation
(BasicSplinePath2D path, double u0, double angle, boolean angleRelative, double time0) Set a path for this object to follow, specifying an initial path parameter and angle.void
setPathInversionLimit
(double limit) Set the inversion limit for a path.void
setPathVelocity
(double pathVelocity) Set the velocity along the path.void
setPosition
(double x, double y, double angle) Set an object's position and orientation.protected void
update
(double t, long simtime) Update the object's state to that at a specified time.Methods inherited from class org.bzdev.anim2d.PlacedAnimationObject2D
getAddToTransform, getAngle, getBBXMax, getBBXMin, getBBYMax, getBBYMin, getReferencePointX, getReferencePointY, getRefPointName, getX, getY, setPosition, setRefPoint, setRefPoint, setRefPointBounds, setRefPointBounds, setRefPointByFraction, setRefPointByName
Methods inherited from class org.bzdev.anim2d.AnimationObject2D
addToFrame, addToFrame, getAnimation, getZorder, isVisible, setVisible, setZorder, setZorder
Methods inherited from class org.bzdev.devqsim.SimObject
addSimulationListener, addTraceSet, bindCallable, bindCallable, bindCallable, bindCallable, bindRunnable, bindRunnable, bindRunnable, bindRunnable, callableObject, callableScript, callScriptFunction, callScriptMethod, clearTraceSets, evalScript, getEventListenerList, getScriptObject, getTraceSets, onDelete, printConfiguration, printConfiguration, printConfiguration, printConfiguration, printConfiguration, printConfiguration, printState, printState, printState, printState, printState, printState, putScriptObject, removeSimulationListener, removeTraceSet, runnableObject, runnableScript, scheduleCall, scheduleCall, scheduleCall, scheduleCall, scheduleCallObject, scheduleScript, scheduleTask, scheduleTask, scheduleTask, scheduleTask, scheduleTaskObject, scheduleTaskScript, startImmediateTask, startImmediateTask, trace, trace, unscheduledTaskThread, unscheduledTaskThread, update, usesTraceSet
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bzdev.graphs.Graph.Graphic
addTo, boundingBox
Methods inherited from interface org.bzdev.obnaming.NamedObjectOps
canDelete, delete, deletePending, getName, isDeleted, isInterned
-
Constructor Details
-
DirectedObject2D
Constructor.- Parameters:
animation
- the animationname
- the name of the object; null for an automatically generated nameintern
- true if the object can be looked up by using the methods inSimulation
; false otherwise.- Throws:
IllegalArgumentException
- typically means a name is already in use- See Also:
-
-
Method Details
-
hasPath
public boolean hasPath()Determine if this object has a path to follow.- Returns:
- true if this object has a path to follow; false otherwise
-
getUpdatedTime
protected double getUpdatedTime()Get the time used by the last call to update.- Returns:
- the time;
- See Also:
-
getU
protected double getU()Get the path parameter at the time specified in the last call to update.- Returns:
- the value of the path parameter u; Double.NaN if no path set
- See Also:
-
getInitialS
protected double getInitialS()Get the distance along the path at the start of a path traversal at the time specified in the last call to update. The value is initialized when a setPath method is called.- Returns:
- the initial distance along the path; Double.NaN if the path is null
-
getInitialU
protected double getInitialU()Get the path parameter for the start of a path traversal.- Returns:
- the initial value of the path parameter; ( Double.NaN if the path is null
-
getS
protected double getS()Get the current distance along the path at the time specified in the last call to update. The distance will be the one corresponding to the time returned bygetUpdatedTime()
.- Returns:
- the distance along the path
- See Also:
-
getU
public double getU(double s) Get the path parameter for a specific distance along the path- Parameters:
s
- the distance along the path from its start (negative distances or distances larger than the length of the path are allowed only for cyclic paths)- Returns:
- the value of the path parameter u; Double.NaN if no path set
-
getS
public double getS(double u) Get the current distance along the path from its start.- Parameters:
u
- the path parameter- Returns:
- the distance; Double.NaN if there is no path
-
getPathInversionLimit
public double getPathInversionLimit()Get the inversion limit that will be used for splines that are created by paths in order to determine the path distance given the path parameter and vice versa. The limit is used when a spline is created.- Returns:
- the path inversion limit; -1.0 if the default will be used.
-
setPathInversionLimit
public void setPathInversionLimit(double limit) Set the inversion limit for a path. This method calls the methodBasicSplinePath2D.setInversionLimit(double)
thus modifying the behavior of the path.- Parameters:
limit
- the inversion limit; negative values if no limit is to be set
-
defaultAngleRelative
protected boolean defaultAngleRelative()Return the default value of the angle-relative flag. This method returnstrue
unless overridden.- Returns:
- the default value for setPath methods
- See Also:
-
setPath
Set the path, specified by an instance of AnimationPath2D. This method callssetPath(AnimationPath2D,double,double,boolean,double)
with appropriate arguments: an initial value of the path parameter u of 0.0, an angle of 0.0, and the angle-relative flag set to its default value (provided by the method defaultAngleRelative()). The path angle function will be set to null unless this behavior is overridden by a subclass, as will the corresponding simulation function. If one is desired, it should be reset.To override the behavior that this class provides, one should override
setPathImplementation(org.bzdev.geom.BasicSplinePath2D,double,double,boolean,double)
.- Parameters:
objectPath
- the path to settime0
- the increment from the current time at which the path should be set.
-
setPath
Set the path. This method callssetPath(BasicSplinePath2D,double,double,boolean,double)
with appropriate arguments: an initial value of the path parameter u of 0.0, an angle of 0.0, and the angle-relative flag set to its default value (provided by the method defaultAngleRelative()). The path angle function will be set to null unless this behavior is overridden by a subclass, as will the corresponding simulation function. If one is desired, it should be reset.To override the behavior that this class provides, one should override
setPathImplementation(org.bzdev.geom.BasicSplinePath2D,double,double,boolean,double)
.- Parameters:
path
- the path the object will followtime0
- the increment from the current time at which the path should be set.
-
setPath
Set the path, using an AnimationPath2D object to specify the path and specifying the angle-relative flag. This method callssetPath(BasicSplinePath2D,double,double,boolean,double)
with appropriate arguments: an initial value of the path parameter u of 0.0, and an angle of 0.0. The path angle function will be set to null unless this behavior is overridden by a subclass, as will the corresponding simulation function. If one is desired, it should be reset.To override the behavior that this class provides, one should override
setPathImplementation(org.bzdev.geom.BasicSplinePath2D,double,double,boolean,double)
.- Parameters:
objectPath
- the object providing the path this object will followangleRelative
- true if the angle (0.0) is measured relative to the path's tangent; false if the angle is measured from the positive X axis in graph coordinate spacetime0
- the increment from the current time at which the object starts moving along the path
-
setPath
Set the path, specifying the angle-relative flag. This method callssetPath(BasicSplinePath2D,double,double,boolean,double)
with appropriate arguments: an initial value of the path parameter u of 0.0 and an angle of 0.0. The path angle function will be set to null unless this behavior is overridden by a subclass, as will the corresponding simulation function. If one is desired, it should be reset.To override the behavior that this class provides, one should override
setPathImplementation(org.bzdev.geom.BasicSplinePath2D,double,double,boolean,double)
.- Parameters:
path
- the path the object will followangleRelative
- true if the angle (0.0)is measured relative to the path's tangent; false if the angle is measured from the positive X axis in graph coordinate spacetime0
- the increment from the current time at which the object starts moving along the path
-
setPath
public final void setPath(AnimationPath2D objectPath, double angle, boolean angleRelative, double time0) Set the path, using an AnimationPath2D object to specify the path and specifying both the angle and the angle-relative flag. This method callssetPath(BasicSplinePath2D,double,double,boolean,double)
with appropriate arguments: an initial value of the path parameter u of 0.0, and an angle of 0.0. The path angle function will be set to null unless this behavior is overridden by a subclass, as will the corresponding simulation function. If one is desired, it should be reset.To override the behavior that this class provides, one should override
setPathImplementation(org.bzdev.geom.BasicSplinePath2D,double,double,boolean,double)
.As a use case for this method, suppose an animation contains an image for a large map and a path that represents a route, and the map is too large to fit in a window. One can use this method to make a GraphView follow the route (one will set the path velocity as well). By setting the angle-relative field to true and the angle to -π/2, the Y axis will always appear to be tangent to the path and the map will seem to rotate as the animation runs, mimicking a GPS display in a vehicle.
- Parameters:
objectPath
- the object providing the path this object will followangle
- the initial angleangleRelative
- true if the angle (0.0) is measured relative to the path's tangent; false if the angle is measured from the positive X axis in graph coordinate spacetime0
- the increment from the current time at which the object starts moving along the path
-
setPath
public final void setPath(BasicSplinePath2D path, double angle, boolean angleRelative, double time0) Set the path, specifying both the initial angle and the angle-relative flag. This method callssetPath(BasicSplinePath2D,double,double,boolean,double)
with appropriate arguments: an initial value of the path parameter u of 0.0 and an angle of 0.0. The path angle function will be set to null, as will the corresponding simulation function. If one of these functions is desired, it should be set after this method is called..To override the behavior that this class provides, one should override
setPathImplementation(org.bzdev.geom.BasicSplinePath2D,double,double,boolean,double)
.As a use case for this method, suppose an animation contains an image for a large map and a path that represents a route, and the map is too large to fit in a window. One can use this method to make a GraphView follow the route (one will set the path velocity as well). By setting the angle-relative field to true and the angle to -π/2, the Y axis will always appear to be tangent to the path and the map will seem to rotate as the animation runs, mimicking a GPS display in a vehicle.
- Parameters:
path
- the path the object will followangle
- the initial angleangleRelative
- true if the angle (0.0)is measured relative to the path's tangent; false if the angle is measured from the positive X axis in graph coordinate spacetime0
- the increment from the current time at which the object starts moving along the path
-
setPath
public final void setPath(AnimationPath2D objectPath, double u0, double angle, boolean angleRelative, double time0) Set a path, specified by an instance of AnimationPath2D and specifying an initial path parameter and angle for the object to follow. The object's position will held at the start of the path until the object's time passes time0. The object's initial angle will match that of a tangent to the path at the object's reference point's current location. The path angle function will be set to null unless this behavior is overridden by a subclass, as will the corresponding simulation function. If one of these functions is desired, it should be set after this method is called.To override the behavior that this class provides, one should override
setPathImplementation(org.bzdev.geom.BasicSplinePath2D,double,double,boolean,double)
.As a use case for this method, suppose an animation contains an image for a large map and a path that represents a route, and the map is too large to fit in a window. One can use this method to make a GraphView follow the route (one will set the path velocity as well). By setting the angle-relative field to true and the angle to -π/2, the Y axis will always appear to be tangent to the path and the map will seem to rotate as the animation runs, mimicking a GPS display in a vehicle.
- Parameters:
objectPath
- the object providing the pathu0
- the path's parameter at a time equal to time0angle
- the initial angleangleRelative
- true if the angle is measured relative to path's tangent; false if the angle is absolutetime0
- the increment from the current time at which the object starts moving along the path
-
setPath
public final void setPath(BasicSplinePath2D path, double u0, double angle, boolean angleRelative, double time0) Set a path for this object to follow, specifying an initial path parameter and angle. The object's position will held at the start of the path until the object's time passes time0. The object's angle will match that of a tangent to the path at the object's reference point's current location. The path angle function will be set to null unless this behavior is overridden by a subclass, as will the corresponding simulation function. If one of these functions is desired, it should be set after this method is called.- Parameters:
path
- the path the object will followu0
- the path's parameter at a time equal to time0angle
- the initial angleangleRelative
- true if the angle is measured relative to path's tangent; false if the angle is absolutetime0
- the increment from the current time at which the object starts moving along the path
-
setPathImplementation
protected void setPathImplementation(BasicSplinePath2D path, double u0, double angle, boolean angleRelative, double time0) Set a path for this object to follow, specifying an initial path parameter and angle. The object's position will held at the start of the path until the object's time passes time0. The object's angle will match that of a tangent to the path at the object's reference point's current location. The path angle function will be set to null, as will the corresponding simulation function. If one is desired, it should be reset after setPath is called. Subclasses that modify how paths are processed should override this method and in most cases call super.setPathImplementation and, of course, document any changes in behavior.- Parameters:
path
- the path the object will followu0
- the path's parameter at a time equal to time0angle
- the initial angleangleRelative
- true if the angle is measured relative to path's tangent; false if the angle is absolutetime0
- the increment from the current time at which the object starts moving along the path
-
angleIsRelative
public boolean angleIsRelative()Test if the angleRelative flag was set when the current path was set. When angleRelative flag the angle function, angular velocity, and angular acceleration are assumed to be computed relative to the tangent of the path. If the angular velocity is zero, the actual angle (the one returned by getAngle()) will be equal to the angle of the tangent to the path.- Returns:
- true if the angleRelative flag was set; false if it was not or if there is no path
-
setAngleRelative
public void setAngleRelative(boolean relative) Set whether or not the angle is relative to the current path. The setPath methods will also set whether or not the angle is relative to the current path. This method allows that to be changed. When the angle-relative flag's value changes, the path angle will be adjusted so that the object does not immediately rotate.- Parameters:
relative
- true if the angle is relative to the current path; false otherwise- Throws:
IllegalStateException
- no path has been defined
-
setPosition
public void setPosition(double x, double y, double angle) Description copied from class:PlacedAnimationObject2D
Set an object's position and orientation. Angles increase in the counterclockwise direction in graph coordinate space with an angle of zero corresponding to a subclass-specified direction, which will typically be one in which the object 'points' towards the positive x axis from position (0.0,0.0); The coordinates (x,y) are the coordinates of a subclass-specific reference point that is in a fixed location relative to the object.- Overrides:
setPosition
in classPlacedAnimationObject2D
- Parameters:
x
- the x coordinate in graph coordinate spacey
- the y coordinate in graph coordinate spaceangle
- the angle giving the object's orientation in radians
-
setAngle
public void setAngle(double angle) Description copied from class:PlacedAnimationObject2D
Set an object's angle. Angles increase in the counterclockwise direction in graph coordinate space with an angle of zero corresponding to a subclass-specified direction, which will typically be one in which the object 'points' towards the positive x axis from position (0.0,0.0).- Overrides:
setAngle
in classPlacedAnimationObject2D
- Parameters:
angle
- the angle giving the object's orientation in radians
-
setPathAngle
public void setPathAngle(double angle) Set angle to use when traversing the current path. The path angle is relative to the path if the angleRelative flag was set to true when the path was constructed or during a subsequent call tosetAngleRelative(boolean)
; otherwise the angle is an absolute angle measured counterclockwise from the positive x axis.- Parameters:
angle
- the angle in radians- Throws:
IllegalStateException
- a path does not exist
-
setAngularVelocity
public void setAngularVelocity(double angularVelocity) Set the angular velocity. Traversing a path will set this value to the current path angular velocity. The changes begin when path traversal starts.- Parameters:
angularVelocity
- the angular velocity in radians per unit time (unit time is typically a second)- See Also:
-
setAngularAcceleration
public void setAngularAcceleration(double angularAcceleration) Set the angular acceleration. Traversing a path will set this value to the current path angular acceleration. The changes begin when path traversal starts.- Parameters:
angularAcceleration
- the angular acceleration in radians per unit time per unit time (unit time is typically a second)- See Also:
-
getAngularVelocity
public double getAngularVelocity()Get the current angular velocity. This is the value provided in the last call tosetAngularVelocity(double)
, possibly updated to the current path angular velocity if a path is being traversed.- Returns:
- the angular velocity in radians per unit time (unit time is typically one second)
-
clearPath
public void clearPath()Clear the path. This will also clear the distance function (if any), the path angle function (if any), and set both the path velocity and path acceleration to zero.This method calls
SimObject.update()
. -
setDistanceByF
Set the function giving the distance along the path as a function of time, setting the function at a specific simulation time. The distance along the path will change when the object's time is updated. When a distance function is provided, the path velocity and acceleration is ignored.This method calls
SimObject.update()
.- Parameters:
f
- the function providing the distance along the path
-
setDistanceBySF
Set the simulation function giving the distance along the path as a function of time, setting the function at a specific simulation time. The distance along the path will change when the object's time is updated. When a distance function is provided, the path velocity and acceleration is ignored.This method calls
SimObject.update()
.- Parameters:
f
- the function providing the distance along the path
-
setAngleByF
Set the function giving the angle of an object as a function of simulation time. When a path is being traversed, this angle function will be ignored if a function provided bysetPathAngleByF(RealValuedFunctOps)
orsetPathAngleBySF(SimFunction)
exists at the current time. Similarly, when an angle function is provided, the path angular velocity and angular acceleration are not used. The angle will change as the object's time is updated.This method calls
SimObject.update()
. The function provided must return an angle in units of radians.- Parameters:
f
- the function providing the angle as a function of time
-
setAngleBySF
Set the simulation function giving the angle of an object as a simulation function of simulation time. When a path is being traversed, this angle function will be ignored if a function provided bysetPathAngleByF(RealValuedFunctOps)
orsetPathAngleBySF(SimFunction)
exists at the current time. Similarly, when an angle function is provided, the path angular velocity and angular acceleration are not used. The angle will change as the object's time is updated.This method calls
SimObject.update()
. The function provided must return an angle in units of radians.- Parameters:
f
- the function providing the angle as a function of time
-
setPathAngleByF
Set the function giving the angle of an object as a function of time measured from the point at which the traversal of a path begins. WhenangleIsRelative()
returns true, the angle function refers to the change in angle relative to the tangent at the current location along a path. When an angle function is provided, the path angular velocity and angular acceleration is not used. The angle will change as the object's time is updated. This function has no effect before a path's traversal starts. If the path traversal has started and a path is configured, this function will be used instead of a function provided bysetAngleByF(RealValuedFunctOps)
.This method calls
SimObject.update()
. The function provided must return an angle in units of radians.- Parameters:
f
- the function providing the angle as a function of time
-
setPathAngleBySF
Set the simulation function giving the angle of an object as a function of time measured from the point at which the traversal of a path begins. WhenangleIsRelative()
returns true, the angle function refers to the change in angle relative to the tangent at the current location along a path. When an angle function is provided, the path angular velocity and angular acceleration is not used. The angle will change as the object's time is updated. This function has no effect before a path's traversal starts. If the path traversal has started and a path is configured, this function will be used instead of a function provided bysetAngleByF(RealValuedFunctOps)
.This method calls
SimObject.update()
. The function provided must return an angle in units of radians.- Parameters:
f
- the function providing the angle as a function of time
-
setPathVelocity
public void setPathVelocity(double pathVelocity) Set the velocity along the path. The value will change as the object's time is updated. When a distance function is provided, the path velocity and acceleration is ignored.This method calls
SimObject.update()
.- Parameters:
pathVelocity
- the velocity of the object along the path.
-
setPathAcceleration
public void setPathAcceleration(double pathAccel) Set the acceleration along the path. The value will change as the object's time is updated. When a distance function is provided, the path velocity and acceleration is ignored.This method calls
SimObject.update()
.- Parameters:
pathAccel
- the object's acceleration along the path
-
setPathAngularVelocity
public void setPathAngularVelocity(double pathAngularVelocity) Set the angular velocity along the path. WhenangleIsRelative()
returns true, the angular velocity refers to the change in angle relative to the tangent at the current location along a path. The angle will change as the object's time is updated. When an angle function is provided, the path angular velocity and angular acceleration is not used.This method calls
SimObject.update()
.- Parameters:
pathAngularVelocity
- the angular velocity of the object while traversing the path
-
setPathAngularAcceleration
public void setPathAngularAcceleration(double pathAngularAccel) Set the angular acceleration along the path WhenangleIsRelative()
returns true, the angular acceleration refers to the change in angle relative to the tangent at the current location along a path. The angle will change as the object's time is updated. When an angle function is provided, the path angular velocity and angular acceleration is not used.This method calls
SimObject.update()
.- Parameters:
pathAngularAccel
- the object's angular acceleration while traversing the path
-
getPathX
protected double getPathX(double u) Get the x coordinate for a point along a path.- Parameters:
u
- the path parameter- Returns:
- the x coordinate; 0.0 if there is no path
-
getPathY
public double getPathY(double u) Get the y coordinate for a point along a path.- Parameters:
u
- the path parameter- Returns:
- the y coordinate; 0.0 if there is no path
-
getPathDxDu
public double getPathDxDu(double u) Get the derivative of the x coordinate for a point along a path with respect to the path parameter.- Parameters:
u
- the path parameter- Returns:
- the derivative of the x coordinate; 0.0 if there is no path
-
getPathDyDu
public double getPathDyDu(double u) Get the derivative of the y coordinate for a point along a path with respect to the path parameter.- Parameters:
u
- the path parameter- Returns:
- the derivative of the y coordinate; 0.0 if there is no path
-
getMaxPathParameter
public double getMaxPathParameter()Get the maximum value of the path parameter. For a closed path, this is the first positive value of the path parameter at which the path repeats itself.- Returns:
- the maximum value of the path parameter; 0.0 if there is no path
-
getPathLength
public double getPathLength()Get the length of the path.- Returns:
- the length of the path; 0.0 if there is no path
-
getPathLength
public double getPathLength(double u1, double u2) Get the length of the path parameter between an initial and final value of the path parameter. The returned value is the same if u1 and u2 are exchanged: lengths are non-negative.- Parameters:
u1
- the initial path parameteru2
- the final path parameter- Returns:
- the length of the path; 0.0 if there is no path
-
getDistance
public double getDistance(double u1, double u2) throws IllegalStateException, IllegalArgumentException Get the distance traversed on a subpath. If u2 < u1, the value returned is negative.This is intended for cases where direction is important.
- Parameters:
u1
- the parameter at the first end point of a subpathu2
- the parameter at the second end point of a subpath- Returns:
- the distance
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
isClosedPath
public boolean isClosedPath()Determine if the path is closed.- Returns:
- true if the path exists and is closed; false otherwise
-
pathExists
public boolean pathExists()Determine if the path exists.- Returns:
- true if the path exists; false otherwise.
-
getPathAngle
public double getPathAngle()Get the path angle. WhenangleIsRelative()
returns true, the path angle is measured relative to the path's tangent in the direction of increasing distance. Otherwise the path angle is measured from the positive x axis. The path angle is used by this class only when a path is set, and the path angle is set when a path is set. -
getPathVelocity
public double getPathVelocity()Get the path velocity.- Returns:
- the speed along the path at the current time
-
getPathAcceleration
public double getPathAcceleration()Get the path acceleration.- Returns:
- the current value of the acceleration.
-
getInitialPathTime
public double getInitialPathTime()Get the initial time at which a path traversal will start. When finite, this is the argument named time0 that was used when the last setPath method was called added to the simulation time when that setPath method was called.- Returns:
- the time at which a path traversal will start; Double.POSITIVE_INFINITY if there is no path
-
update
protected void update(double t, long simtime) Update the object's state to that at a specified time. The values of t passed to this method should form an increasing sequence. The default implementation's behavior depends on whether functions are provided. A distance function, path velocity, path acceleration, or angle function is not used when there is no path, although the angular acceleration and angular velocity will be used if these are nonzero.- If a distance function is provided, that function is used to determine the new value of s (the distance along the path from its start) at time τ, with the path velocity and acceleration determined by that function's first and second derivatives (if not implemented, the path velocity and/or acceleration is set to Double.NaN). The time τ is the difference between the current time t and the time time0 at which the path traversal starts.
- If a distance function is not provided, the path velocity and path acceleration are used to determine the new value of s, and the path velocity is updated as well.
- If an angle function is provided, that function is used to determine the new angle, and its derivatives, if implemented provide the angular velocity and angular acceleration. The time argument $tau; is the difference between the current time t and the time time0 at which the path traversal starts. If the path was set with the flag angleRelative set to true, the angle is added to the tangent at the object's new position along the path; otherwise the angle is measured counterclockwise from the direction of the positive X axis.
- If an angle function is not provided the path angular velocity and path angular acceleration are used to compute the change in angle from the last time update was called. If the path was set with the flag angleRelative set to true, the angle is added to the angle of the tangent to the path at its new location; otherwise the angle is measured counterclockwise from the direction of the positive X axis.
setPath(org.bzdev.geom.BasicSplinePath2D,double,double,boolean,double)
orsetPath(AnimationPath2D,double,double,boolean,double)
, but may be subsequently changed by callingsetAngleRelative(boolean)
.If a velocity or acceleration has the value Double.NaN, it is treated as if its value were 0.0. In cases where one needs to obtain the previous value of s, one can override this method and obtain the previous value by calling
getS()
before callingsuper.update
. -
printConfiguration
Print this simulation object's configuration. Documentation for the use of this method is provided by the documentation for theSimObject
methodSimObject.printConfiguration(String,String,boolean,PrintWriter)
.When the second argument has a value of true, the object name and class name will be printed in a standard format with its indentation provided by the iPrefix argument. In addition, the configuration that is printed includes the following items.
Defined in
AnimationObject2D
:- the Z-order.
- whether or not this object is visible.
PlacedAnimationObject2D
:- the reference-point name (if any).
- the reference point location.
- the reference point bounds (minimum and maximum X and Y values for the rectangle to which the reference point names refer).
DirectedObject2D
:- the path this object will follow: either the name of an
instance of AnimationPath2D or the configuration of a
BasicSplinePath2D as provided by its method
BasicSplinePath2D.printTable(String,Appendable)
. - the distance along a path for its starting point (the initial distance).
- the initial value of the path's parameter.
- the time at which a path traversal should start.
- the initial value for whether or not the angle for the object is relative to the path's tangent or absolute.
- the distance function.
- a flag indicating if the distance function is set.
- the path velocity.
- the path acceleration.
- the path inversion limit (described in the documentation for
getPathInversionLimit()
.
- Overrides:
printConfiguration
in classPlacedAnimationObject2D
- Parameters:
iPrefix
- the prefix to use for an initial line when printName is true with null treated as an empty stringprefix
- a prefix string (typically whitespace) to put at the start of each line other than the initial line that is printed when printName is trueprintName
- requests printing the name of an objectout
- the output print writer
-
printState
Print this simulation object's state. Documentation for the use of this method is provided by the documentation for theSimObject
methodSimObject.printState(String,String,boolean,PrintWriter)
.When the third argument has a value of true, the object name and class name will be printed in a standard format with its indentation provided by the iPrefix argument. In addition, the state that is printed includes the following items.
Defined in
PlacedAnimationObject2D
:- the X coordinate of this object.
- the Y coordinate of this object.
- the angle for this object, measured counterclockwise.
DirectedObject2D
:- the name of the path (if any) this object can follow.
- the path parameter.
- the path distance.
- the angle-relative flag.
- the velocity along the path (NaN if undefined). When a distance function is used, its derivative, if implemented, determines this value.
- the acceleration along the path (NaN if undefined). When a distance function is used, its second derivative, if implemented, determines this value.
- the path angle. The angle is measured relative to the path's tangent in the direction of an increasing path parameter when the angle-relative flag is true; otherwise it is measured relative to the X axis. Angles are measured counterclockwise.
- the angular velocity. When a path-angle function is used, its derivative, if implemented, determines this value.
- the angular acceleration. When a path-angle function is used, its derivative, if implemented, determines this value.
- the angular acceleration. When a path-angle function is used, its derivative, if implemented, determines this value.
- the time at which this data was last updated.
- Overrides:
printState
in classPlacedAnimationObject2D
- Parameters:
iPrefix
- the prefix to use for an initial line when printName is true with null treated as an empty stringprefix
- a prefix string (typically whitespace) to put at the start of each line other than the initial line that is printed when printName is trueprintName
- requests printing the name of an objectout
- the output print writer
-
clone
Creates and returns a copy of this object. This method will throw the exception CloneNotSupportedException if the object is interned.- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
- a clone could not be created- See Also:
-
isInterned
public boolean isInterned()Determine if an object is interned in a object namer's tables.- Specified by:
isInterned
in interfaceNamedObjectOps
- Returns:
- true if the object is interned; false if not
-
getObjectNamer
Get the object namer for a named object.- Returns:
- the object namer for this named object
-
getName
Get an object's name.- Specified by:
getName
in interfaceNamedObjectOps
- Returns:
- the name of the object
-
canDelete
public boolean canDelete()Determine if this named object can be deleted. A named object can be deleted if the method delete has not been called and if the object is not in a state that prevents the object from being deleted. Subclasses that override this method must call canDelete() for their superclasses and return false if the superclass' canDelete method returns false. The default method returns true if delete() has not been called and returned true.- Specified by:
canDelete
in interfaceNamedObjectOps
- Returns:
- true if this object can be deleted; false otherwise
-
delete
public final boolean delete()Delete an object. An object can only be deleted once. If this method returns true, the object (if interned) will have been removed from the object namer tables.The implementations provided by
DefaultNamedObect
and generated because of a@NamedObject
annotation provide a protected method named onDelete. A subclass that overrides onDelete() must call the onDelete method of its superclass after it's onDelete method has been called and any cleanup actions performed. In some cases, this may happen at a later time (e.g., if a thread is used for some of the cleanup operations or if it is otherwise necessary to wait).- Specified by:
delete
in interfaceNamedObjectOps
- Returns:
- true if the deletion request was accepted; false otherwise
-
isDeleted
public final boolean isDeleted()Determine if an object has been deleted. An object is deleted if the method delete() has been called and returned true.- Specified by:
isDeleted
in interfaceNamedObjectOps
- Returns:
- true if deleted; false otherwise
-
deletePending
public final boolean deletePending()Determine if an object is being deleted. An deletion is pending if the method delete() has been called and returned true but the deletion has not been completed.- Specified by:
deletePending
in interfaceNamedObjectOps
- Returns:
- true if deletion is pending; false otherwise
-