Learn R Programming

geostats (version 1.6)

pendulum: 3-magnet pendulum experiment

Description

Simulates the 3-magnet pendulum experiment, starting at a specified position with a given start velocity.

Usage

pendulum(
  startpos = c(-2, 2),
  startvel = c(0, 0),
  src = rbind(c(0, 0), c(0.5, sqrt(0.75)), c(1, 0)),
  plot = TRUE
)

Value

the end position of the pendulum

Arguments

startpos

2-element vecotor with the initial position

startvel

2-element vector with the initial velocity

src

\(n \times 2\) matrix with the positions of the magnets

plot

logical. If TRUE, generates a plot with the trajectory of the pendulum.

Examples

Run this code
p <- par(mfrow=c(1,2))
pendulum(startpos=c(2.1,2))
pendulum(startpos=c(1.9,2))
par(p)

Run the code above in your browser using DataLab