kinem

package
v0.0.0-...-c7e50b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: CC0-1.0, CC0-1.0 Imports: 2 Imported by: 2

README

Package kinem

import "gitlab.com/fospathi/maf/kinem"

Go package kinem describes geometric motions in terms of displacement, velocity, and acceleration.

Kinematics vs kinetics

  • Kinematics: provides a geometrical description of the possible motions. Does not seek to answer the question of why bodies move as they do.

  • Kinetics/Dynamics: describes the forces that cause motions.

This package only deals with kinematics.

Development status

Package kinem is unstable; expect breaking changes with every commit.

License

CC0
To the extent possible under law, Christian Stewart has waived all copyright and related or neighboring rights to kinem. This work is published from: United Kingdom.

Documentation

Index

Constants

View Source
const G = -9.80665

G is an approximation of the acceleration due to gravity on the Earth's surface, measured in m/s².

Variables

This section is empty.

Functions

func Curvature

func Curvature(mot Motion, t float64) float64

Curvature is the magnitude of the curvature for the trace of the motion at the given parameter value.

func Frenet

func Frenet(mot Motion, t float64) maf.Basis

Frenet frame at the given parameter value on the trace of the given motion.

The returned orthonormal basis has the X-axis as the velocity, the Y-axis as the normal, and the Z-axis as the binormal, at t.

func NumericalAccel

func NumericalAccel(mot Velocityer, t float64) maf.Vec

NumericalAccel is a rough approximation of the given motion's acceleration at the given parameter value.

func NumericalAcceleration

func NumericalAcceleration(mot Displacementer, t float64) maf.Vec

NumericalAcceleration is a very rough approximation of the given motion's acceleration at the given parameter value.

func NumericalVelocity

func NumericalVelocity(mot Displacementer, t float64) maf.Vec

NumericalVelocity is a rough approximation of the given motion's velocity at the given parameter value.

Types

type Archimedean

type Archimedean struct {
	// Initial displacement from the origin along the positive X-axis.
	D float64
	// The magnitude of the constant radial speed component of the particle's
	// motion.
	V float64
	// The magnitude of the constant angular velocity component of the
	// particle's motion (measured in radians per time unit).
	W float64
}

Archimedean is the spiral motion of a particle moving along a radial path on a rotating turntable.

The particle moves outwards from the centre and the turntable rotates anticlockwise around the Z-axis with the radial line starting at the positive X-axis.

func (Archimedean) Acceleration

func (mot Archimedean) Acceleration(t float64) maf.Vec

Acceleration of the motion at the given motion parameter.

func (Archimedean) Displacement

func (mot Archimedean) Displacement(t float64) maf.Vec

Displacement of the motion from the origin at the given motion parameter.

func (Archimedean) Velocity

func (mot Archimedean) Velocity(t float64) maf.Vec

Velocity of the motion at the given motion parameter.

type Circular

type Circular struct {
	// The radius of the circular motion.
	R float64
	// The constant angular velocity of the circular motion measured in radians
	// per unit time.
	W float64
}

Circular is a uniform circular motion.

The particle starts on the positive X-axis and is constrained to the XY-plane.

func (Circular) Acceleration

func (mot Circular) Acceleration(t float64) maf.Vec

Acceleration of the motion at the given motion parameter.

func (Circular) Displacement

func (mot Circular) Displacement(t float64) maf.Vec

Displacement of the motion from the origin at the given motion parameter.

func (Circular) Velocity

func (mot Circular) Velocity(t float64) maf.Vec

Velocity of the motion at the given motion parameter.

type Components

type Components struct {
	Rotational    maf.Vec
	Translational maf.Vec
}

Components of a vector property of a rigid bodies motion.

type Displacementer

type Displacementer interface {
	Displacement(t float64) maf.Vec
}

A Displacementer is a motion with a known displacement at a given parameter value.

type Helical

type Helical struct {
	// The pitch of the helix, that is, the distance travelled along the Z-axis
	// in one complete helix turn.
	P float64
	// The radius of the circular motion in the XY plane.
	R float64
	// The constant angular velocity of the circular motion in the XY plane
	// measured in radians per unit time.
	W float64
}

Helical is the helical motion of a particle moving along a circular path on a rising platform.

func (Helical) Acceleration

func (mot Helical) Acceleration(t float64) maf.Vec

Acceleration of the motion at the given motion parameter.

func (Helical) Displacement

func (mot Helical) Displacement(t float64) maf.Vec

Displacement of the motion from the origin at the given motion parameter.

func (Helical) Velocity

func (mot Helical) Velocity(t float64) maf.Vec

Velocity of the motion at the given motion parameter.

type Motion

type Motion interface {
	Displacement(t float64) maf.Vec
	Velocity(t float64) maf.Vec
	Acceleration(t float64) maf.Vec
}

A Motion of a particle.

type Particle

type Particle struct {
	// The fixed angular displacement of the particle measured from some
	// reference position.
	Angle float64
	// The fixed perpendicular distance of the particle from the rotation axis.
	Distance float64
}

A Particle of a rigid body.

type Projectile

type Projectile struct {
	// The acceleration. A positive acceleration is in the direction of the
	// positive Y-axis.
	A float64
	// The initial velocity.
	U maf.Vec
}

Projectile motion constrained to the XY-plane and starting at the origin and subject to a constant acceleration parallel to the Y-axis.

func (Projectile) Acceleration

func (mot Projectile) Acceleration(t float64) maf.Vec

Acceleration of the motion at the given motion parameter.

func (Projectile) Displacement

func (mot Projectile) Displacement(t float64) maf.Vec

Displacement of the motion from the origin at the given motion parameter.

func (Projectile) LaunchAngle

func (mot Projectile) LaunchAngle() float64

LaunchAngle of the projectile.

func (Projectile) TurningPoint

func (mot Projectile) TurningPoint() maf.Vec

TurningPoint is the position in the trace of the motion at which the projectile changes direction.

The motion's acceleration shall be non zero.

func (Projectile) Velocity

func (mot Projectile) Velocity(t float64) maf.Vec

Velocity of the motion at the given motion parameter.

type ProjectileTargeter

type ProjectileTargeter struct {
	// The acceleration. A positive acceleration is in the direction of the
	// positive Y-axis.
	A float64
	// The target to hit with a projectile launched from the origin. Shall not
	// coincide with the origin.
	Target maf.Vec
}

ProjectileTargeter finds projectile motions which are launched from the origin and that will hit a target in the XY-plane.

func (ProjectileTargeter) FromLaunchAngle

func (pt ProjectileTargeter) FromLaunchAngle(la float64) (Projectile, bool)

FromLaunchAngle fixes the projectile's launch angle, measured in radians, and attempts to find a solution.

The launch angle shall be confined to the range -Pi/2...Pi/2 which is relative to the positive or negative X-axis as appropriate.

If the returned bool value is false then there is no solution.

Special cases

In the special case where all of the following three conditions apply

  1. the target is vertically above or below the origin
  2. the launch angle is +Pi/2 or -Pi/2 respectively
  3. the acceleration direction is down or up respectively

then, of the infinite number of projectile solutions, the one chosen is that where the peak of the projectile's motion coincides with the target.

In the special case where all of the following three conditions apply

  1. the target is vertically above or below the origin
  2. the launch angle is -Pi/2 or +Pi/2 respectively
  3. the acceleration direction is up or down respectively

then, it suffices to simply let the projectile fall under the motion's acceleration and the initial velocity of the returned projectile is zero.

func (ProjectileTargeter) FromSpeed

func (pt ProjectileTargeter) FromSpeed(u float64) (
	Projectile, Projectile, int,
)

FromSpeed fixes the projectile's initial positive speed and attempts to find a solution.

The int return value is the number of found projectiles, either 0, 1, or 2, that coincide with the target and have the argument initial speed.

In the case of two found projectiles with the target's X !~= 0 then the first of the returned projectiles launches closer to the +/- X-axis.

In the case of two found projectiles, with the target's X ~= 0 and the acceleration and target displacement vectors in the same direction, the first of the returned projectiles will have the shortest time of flight to the target.

type RollingWheel

type RollingWheel struct {
	// Wheel radius.
	R float64
	// Wheel angular velocity. Clockwise (as in moving right) is positive.
	W float64
}

RollingWheel is the rolling motion of a non-slipping wheel rolling at constant velocity along the positive X-axis.

func (RollingWheel) Motion

Motion of the given particle on the receiver rolling wheel.

The particle's angle is the initial clockwise angular displacement from the wheel radius which emits from the centre in the positive Y-axis direction.

type RollingWheelParticle

type RollingWheelParticle struct {
	// contains filtered or unexported fields
}

RollingWheelParticle is the motion of a particle on a rolling wheel.

func (RollingWheelParticle) Acceleration

func (mot RollingWheelParticle) Acceleration(t float64) maf.Vec

Acceleration of the motion at the given motion parameter.

func (RollingWheelParticle) Accelerations

func (mot RollingWheelParticle) Accelerations(t float64) Components

Accelerations of the motion at the given motion parameter.

func (RollingWheelParticle) Displacement

func (mot RollingWheelParticle) Displacement(t float64) maf.Vec

Displacement of the motion from the origin at the given motion parameter.

func (RollingWheelParticle) Velocities

func (mot RollingWheelParticle) Velocities(t float64) Components

Velocities of the motion at the given motion parameter.

func (RollingWheelParticle) Velocity

func (mot RollingWheelParticle) Velocity(t float64) maf.Vec

Velocity of the motion at the given motion parameter.

type Velocityer

type Velocityer interface {
	Velocity(t float64) maf.Vec
}

A Velocityer is a motion with a known velocity at a given parameter value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL