Traj3DAcceleration | R Documentation |
Returns an approximation of the acceleration of a trajectory at each point using the second-order central finite differences.
Traj3DAcceleration(trj3d)
trj3d |
3-dimensional trajectory whose acceleration is to be calculated. |
trajr
trajectories, which consist of straight line displacements
between sampled locations, do not contain enough information to correctly
derive velocity or acceleration. Since we have to assume a constant velocity
at each step, the first derivative is discontinuous. Acceleration, therefore,
is zero during each step and infinite at each change of velocity. The
approximation implemented by this function assumes that acceleration occurs
over a period of time: half the duration of the previous step plus half the
duration of the next step.
The function Traj3DSpeed
, despite its name, can be used to
calculate the magnitude of the acceleration vectors returned by this function.
Numeric matrix of 3D acceleration vectors. Each row represents the
acceleration at a point in the trajectory. Columns are named "'x'", "'y'"
and "'z'". The vector has an attribute, trj
, with the trajectory as
its value. The first and last values will always be NA
, since
acceleration cannot be estimated for those points.
Traj3DVelocity
for calculating velocity,
Traj3DResampleTime
and Traj3DRediscretize
to
resample a trajectory to fixed time or length steps.
## Not run:
library(rgl)
# Plot a trajectory and its acceleration in 3D, using the rgl package
# Function to add acceleration vectors as arrows to a 3D trajectory plot
Acc3DArrows <- function(acc, scale = 0.0001, trj3d = attr(acc, "trj3d"), ...) {
cols <- c("x", "y", "z")
sapply(seq_len(nrow(t3) - 2) + 1, function(r) {
arrow3d(t3[r, cols], t3[r, cols] + acc[r, ] * scale, type = "extrusion", ...)
})
}
plot3d(trj3d$x, trj3d$y, trj3d$z, type = 'l')
Acc3DArrows(Traj3DAcceleration(trj3d), col = 2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.