Documentation
¶
Index ¶
- Constants
- func CalculateByCurve(data []DataPoint, curve []CurvePoint, mach float64) float64
- type Ammunition
- type Atmosphere
- func (a Atmosphere) Altitude() unit.Distance
- func (a Atmosphere) Humidity() float64
- func (a Atmosphere) HumidityInPercents() float64
- func (a Atmosphere) Mach() unit.Velocity
- func (a Atmosphere) Pressure() unit.Pressure
- func (a Atmosphere) String() string
- func (a Atmosphere) Temperature() unit.Temperature
- type BallisticCoefficient
- type CurvePoint
- type DataPoint
- type Projectile
- func (v Projectile) BallisticCoefficient() BallisticCoefficient
- func (v Projectile) BulletDiameter() unit.Distance
- func (v Projectile) BulletLength() unit.Distance
- func (v Projectile) BulletWeight() unit.Weight
- func (v Projectile) GetBallisticCoefficient() float64
- func (v Projectile) HasDimensions() bool
- type ShotParameters
- type Timespan
- type TrajectoryCalculator
- func (v TrajectoryCalculator) MaximumCalculatorStepSize() unit.Distance
- func (v *TrajectoryCalculator) SetMaximumCalculatorStepSize(x unit.Distance)
- func (v TrajectoryCalculator) SightAngle(ammunition Ammunition, weapon Weapon, atmosphere Atmosphere) unit.Angular
- func (v TrajectoryCalculator) Trajectory(ammunition Ammunition, weapon Weapon, atmosphere Atmosphere, ...) []TrajectoryData
- type TrajectoryData
- func (v TrajectoryData) Drop() unit.Distance
- func (v TrajectoryData) DropAdjustment() unit.Angular
- func (v TrajectoryData) Energy() unit.Energy
- func (v TrajectoryData) MachVelocity() float64
- func (v TrajectoryData) OptimalGameWeight() unit.Weight
- func (v TrajectoryData) Time() Timespan
- func (v TrajectoryData) TravelledDistance() unit.Distance
- func (v TrajectoryData) Velocity() unit.Velocity
- func (v TrajectoryData) Windage() unit.Distance
- func (v TrajectoryData) WindageAdjustment() unit.Angular
- type TwistInfo
- type Weapon
- type WindInfo
- type ZeroInfo
- func CreateZeroInfo(distance unit.Distance) ZeroInfo
- func CreateZeroInfoWithAnotherAmmo(distance unit.Distance, ammo Ammunition) ZeroInfo
- func CreateZeroInfoWithAnotherAmmoAndAtmosphere(distance unit.Distance, ammo Ammunition, atmosphere Atmosphere) ZeroInfo
- func CreateZeroInfoWithAtmosphere(distance unit.Distance, atmosphere Atmosphere) ZeroInfo
Constants ¶
const BC = 1
BC is the type of the ballisic coefficient value: Ballicitic Coefficient
const DragTableG1 byte = 1
DragTableG1 is identifier for G1 ballistic table
const DragTableG2 byte = 2
DragTableG2 is identifier for G2 ballistic table
const DragTableG5 byte = 3
DragTableG5 is identifier for G5 ballistic table
const DragTableG6 byte = 4
DragTableG6 is identifier for G6 ballistic table
const DragTableG7 byte = 5
DragTableG7 is identifier for G7 ballistic table
const DragTableG8 byte = 6
DragTableG8 is identifier for G8 ballistic table
const DragTableGC byte = 8
DragTableGC for a custom drag table
const DragTableGS byte = 7
DragTableGS is identifier for GL ballistic table
const FF = 2
FF is the type of the ballisic coefficient value: Form Factor
const PIR = 2.08551e-04
PIR = (PI/8)*(RHO0/144)
const TwistLeft byte = 2
TwistLeft is the flag indiciating that the barrel is left-hand twisted
const TwistRight byte = 1
TwistRight is the flag indiciating that the barrel is right-hand twisted
Variables ¶
This section is empty.
Functions ¶
func CalculateByCurve ¶
func CalculateByCurve(data []DataPoint, curve []CurvePoint, mach float64) float64
CalculateByCurve calculates a drag value using pretabulted or data data and curve created by CalculateCurve
Types ¶
type Ammunition ¶
type Ammunition struct {
// contains filtered or unexported fields
}
Ammunition struct keeps the des of ammunition (e.g. projectile loaded into a case shell)
func CreateAmmunition ¶
func CreateAmmunition(bullet Projectile, muzzleVelocity unit.Velocity) Ammunition
CreateAmmunition creates the description of the ammunition
func (Ammunition) Bullet ¶
func (v Ammunition) Bullet() Projectile
Bullet returns the description of the projectile
func (Ammunition) MuzzleVelocity ¶
func (v Ammunition) MuzzleVelocity() unit.Velocity
MuzzleVelocity returns the velocity of the projectile at the muzzle
type Atmosphere ¶
type Atmosphere struct {
// contains filtered or unexported fields
}
Atmosphere describes the atmosphere conditions
func CreateAtmosphere ¶
func CreateAtmosphere(altitude unit.Distance, pressure unit.Pressure, temperature unit.Temperature, humidity float64) (Atmosphere, error)
CreateAtmosphere creates the atmosphere with the specified parameter
func CreateDefaultAtmosphere ¶
func CreateDefaultAtmosphere() Atmosphere
CreateDefaultAtmosphere creates a default atmosphere used in ballistic calculations
func CreateICAOAtmosphere ¶
func CreateICAOAtmosphere(altitude unit.Distance) Atmosphere
CreateICAOAtmosphere creates default ICAO atmosphere for the specified altitude
func (Atmosphere) Altitude ¶
func (a Atmosphere) Altitude() unit.Distance
Altitude returns the ground level altitude over the sea level
func (Atmosphere) Humidity ¶
func (a Atmosphere) Humidity() float64
Humidity returns the relative humidity set in 0 to 1 coefficient
multiply this value by 100 to get percents
func (Atmosphere) HumidityInPercents ¶
func (a Atmosphere) HumidityInPercents() float64
HumidityInPercents returns relative humidity in percents (0..100)
func (Atmosphere) Mach ¶
func (a Atmosphere) Mach() unit.Velocity
Mach returns the speed of sound at the atmosphere with such parameters
func (Atmosphere) Pressure ¶
func (a Atmosphere) Pressure() unit.Pressure
Pressure returns the pressure at the ground level
func (Atmosphere) String ¶
func (a Atmosphere) String() string
func (Atmosphere) Temperature ¶
func (a Atmosphere) Temperature() unit.Temperature
Temperature returns the temperature at the ground level
type BallisticCoefficient ¶
type BallisticCoefficient struct {
// contains filtered or unexported fields
}
BallisticCoefficient keeps data about ballistic coefficient of a projectile
The ballistic coefficient (BC) of a body is a measure of its ability to overcome air resistance in flight.
The small arm ballistics, BC is expressed vs a standard projectile. Different ballistic tables uses different standard projectiles, for example G1 uses flat based 2 caliber length with a 2 caliber ogive
G1 and G7 are the most used for small arms ballistics
func CreateBallisticCoefficient ¶
func CreateBallisticCoefficient(value float64, dragTable byte) (BallisticCoefficient, error)
CreateBallisticCoefficient creates ballistic coefficient object using the ballistic coefficient value and ballistic table.
func CreateBallisticCoefficientForCustomDragFunction ¶
func CreateBallisticCoefficientForCustomDragFunction(value float64, valueType byte, dragTable dragFunction) (BallisticCoefficient, error)
CreateBallisticCoefficient creates ballistic coefficient object using the the custom drag function
func (BallisticCoefficient) Drag ¶
func (v BallisticCoefficient) Drag(mach float64) float64
Drag calculates the aerodynamic drag (deceleration factor) calculated for the speed expressed in mach (speed of sound)
func (BallisticCoefficient) Table ¶
func (v BallisticCoefficient) Table() byte
Table return the name of the ballistic table
func (BallisticCoefficient) Value ¶
func (v BallisticCoefficient) Value() float64
Value returns the ballistic coefficient value
func (BallisticCoefficient) ValueType ¶
func (v BallisticCoefficient) ValueType() byte
ValueType returns the ballistic coefficient value type (BC or FF)
type CurvePoint ¶
type CurvePoint struct {
A, B, C float64
}
CurvePoint is an approximation of drag to speed function curve made on the base of the ballistic
func CalculateCurve ¶
func CalculateCurve(dataPoints []DataPoint) []CurvePoint
CalculateCurve calculates a curve for CalculateByCurve function using pretabulated or radar data
type DataPoint ¶
type DataPoint struct {
A, B float64
}
DataPoint is one value of the ballistic table used in table-based calculations below
The calculation is based on original JavaScript code by Alexandre Trofimov
type Projectile ¶
type Projectile struct {
// contains filtered or unexported fields
}
Projectile keeps description of a projectile
func CreateProjectile ¶
func CreateProjectile(ballisticCoefficient BallisticCoefficient, weight unit.Weight) Projectile
CreateProjectile create projectile description without dimensions.
If no dimensions set, the trajectory calculator won't be able to calculate spin drift.
func CreateProjectileWithDimensions ¶
func CreateProjectileWithDimensions(ballisticCoefficient BallisticCoefficient, bulletDiameter unit.Distance, bulletLength unit.Distance, weight unit.Weight) Projectile
CreateProjectileWithDimensions creates the description of a projectile with dimensions (diameter and length)
Dimensions are only required if you want to take into account projectile spin drift. TwistInfo must be also set in this case.
func (Projectile) BallisticCoefficient ¶
func (v Projectile) BallisticCoefficient() BallisticCoefficient
BallisticCoefficient returns ballistic coefficient of the projectile
func (Projectile) BulletDiameter ¶
func (v Projectile) BulletDiameter() unit.Distance
BulletDiameter returns the diameter (caliber) of the projectile
func (Projectile) BulletLength ¶
func (v Projectile) BulletLength() unit.Distance
BulletLength return the length of the bullet
func (Projectile) BulletWeight ¶
func (v Projectile) BulletWeight() unit.Weight
BulletWeight returns weight of the projectile
func (Projectile) GetBallisticCoefficient ¶
func (v Projectile) GetBallisticCoefficient() float64
func (Projectile) HasDimensions ¶
func (v Projectile) HasDimensions() bool
HasDimensions returns the flag indicating whether the projectile has dimensions set
type ShotParameters ¶
type ShotParameters struct {
// contains filtered or unexported fields
}
ShotParameters struct keeps parameters of the shot to be calculated
func CreateShotParameterUnlevel ¶
func CreateShotParameterUnlevel(sightAngle unit.Angular, maxDistance unit.Distance, step unit.Distance, shotAngle unit.Angular, cantAngle unit.Angular) ShotParameters
CreateShotParameterUnlevel creates the parameter of the shot aimed at the target which is not on th same level as the shooter
sightAngle - is the angle between scope centerline and the barrel centerline
shotAngle - is the angle between lines drawn from the shooter to the target and the horizon. The positive angle means that the target is higher and the negative angle means that the target is lower
func CreateShotParameters ¶
func CreateShotParameters(sightAngle unit.Angular, maxDistance unit.Distance, step unit.Distance) ShotParameters
CreateShotParameters creates parameters of the shot
sightAngle - is the angle between scope centerline and the barrel centerline
func (ShotParameters) CantAngle ¶
func (v ShotParameters) CantAngle() unit.Angular
CantAngle returns the cant angle (the angle between centers of scope and the barrel projection and zenith line)
func (ShotParameters) MaximumDistance ¶
func (v ShotParameters) MaximumDistance() unit.Distance
MaximumDistance returns the maximum distance to be calculated
func (ShotParameters) ShotAngle ¶
func (v ShotParameters) ShotAngle() unit.Angular
ShotAngle returns the angle of the short
func (ShotParameters) SightAngle ¶
func (v ShotParameters) SightAngle() unit.Angular
SightAngle returns the angle of the sight
func (ShotParameters) Step ¶
func (v ShotParameters) Step() unit.Distance
Step returns the step between calculation results
type Timespan ¶
type Timespan struct {
// contains filtered or unexported fields
}
Timespan keeps the amount of time spent
func (Timespan) TotalSeconds ¶
TotalSeconds returns the total number of seconds
type TrajectoryCalculator ¶
type TrajectoryCalculator struct {
// contains filtered or unexported fields
}
TrajectoryCalculator table is used to calculate the trajectory of a projectile shot with the parameters specified
func CreateTrajectoryCalculator ¶
func CreateTrajectoryCalculator() TrajectoryCalculator
CreateTrajectoryCalculator creates and instance of the trajectory calculator
func (TrajectoryCalculator) MaximumCalculatorStepSize ¶
func (v TrajectoryCalculator) MaximumCalculatorStepSize() unit.Distance
MaximumCalculatorStepSize returns the maximum size of one calculation iteration.
func (*TrajectoryCalculator) SetMaximumCalculatorStepSize ¶
func (v *TrajectoryCalculator) SetMaximumCalculatorStepSize(x unit.Distance)
SetMaximumCalculatorStepSize sets the maximum size of one calculation iteration.
As the generic rule, the maximum step of the calculation must not be greater than a half of the step used in the short parameter. The smaller value is, the calculation is more precise but takes more time to calculate. From practical standpoint the value in range from 0.5 to 5 feet produces good enough accuracy.
func (TrajectoryCalculator) SightAngle ¶
func (v TrajectoryCalculator) SightAngle(ammunition Ammunition, weapon Weapon, atmosphere Atmosphere) unit.Angular
SightAngle calculates the sight angle for a rifle with scope height specified and zeroed using the ammo specified at the range specified and under the conditions (atmosphere) specified.
The calculated value is to be used as sightAngle parameter of the ShotParameters structure
func (TrajectoryCalculator) Trajectory ¶
func (v TrajectoryCalculator) Trajectory(ammunition Ammunition, weapon Weapon, atmosphere Atmosphere, shotInfo ShotParameters, windInfo []WindInfo) []TrajectoryData
Trajectory calculates the trajectory with the parameters specified
type TrajectoryData ¶
type TrajectoryData struct {
// contains filtered or unexported fields
}
TrajectoryData structure keeps information about one point of the trajectory.
func (TrajectoryData) Drop ¶
func (v TrajectoryData) Drop() unit.Distance
Drop returns the shorted distance between the projectile and the shot line
The positive value means the the projectile is above this line and the negative value means that the projectile is below this line
func (TrajectoryData) DropAdjustment ¶
func (v TrajectoryData) DropAdjustment() unit.Angular
DropAdjustment returns the angle between the shot line and the line from the muzzle to the current projectile position in the plane perpendicular to the ground
func (TrajectoryData) Energy ¶
func (v TrajectoryData) Energy() unit.Energy
Energy returns the kinetic energy of the projectile
func (TrajectoryData) MachVelocity ¶
func (v TrajectoryData) MachVelocity() float64
MachVelocity returns the proportion between the current projectile velocity and the speed of the sound
func (TrajectoryData) OptimalGameWeight ¶
func (v TrajectoryData) OptimalGameWeight() unit.Weight
OptimalGameWeight returns the weight of game to which a kill shot is probable with the kinetic energy that the projectile currently have
func (TrajectoryData) Time ¶
func (v TrajectoryData) Time() Timespan
Time return the amount of time spent since the shot moment
func (TrajectoryData) TravelledDistance ¶
func (v TrajectoryData) TravelledDistance() unit.Distance
TravelledDistance returns the distance measured between the muzzle and the projection of the current bullet position to the line between the muzzle and the target
func (TrajectoryData) Velocity ¶
func (v TrajectoryData) Velocity() unit.Velocity
Velocity returns the current projectile velocity
func (TrajectoryData) Windage ¶
func (v TrajectoryData) Windage() unit.Distance
Windage returns the distance to which the projectile is displaced by wind
func (TrajectoryData) WindageAdjustment ¶
func (v TrajectoryData) WindageAdjustment() unit.Angular
WindageAdjustment returns the angle between the shot line and the line from the muzzle to the current projectile position in the place parallel to the ground
type TwistInfo ¶
type TwistInfo struct {
// contains filtered or unexported fields
}
TwistInfo contains the rifling twist information
The rifling twist is used to calculate spin drift only
func CreateTwist ¶
CreateTwist creates twist information
Direction must be either Twist_Right or Twist_Left constant
type Weapon ¶
type Weapon struct {
// contains filtered or unexported fields
}
Weapon struct contains the weapon description
func CreateWeapon ¶
CreateWeapon creates the weapon definition with no twist info
If no twist info is set, spin drift won't be calculated
func CreateWeaponWithTwist ¶
CreateWeaponWithTwist creates weapon description with twist info
If twist info AND bullet dimensions are set, spin drift will be calculated
func (Weapon) ClickValue ¶
ClickValue returns the value of one click of the scope
func (Weapon) HasTwist ¶
HasTwist returns the flag indicating whether the rifling twist information is set
func (*Weapon) SetClickValue ¶
SetClickValue sets the value of one click of the scope
func (Weapon) SightHeight ¶
SightHeight returns the height of the sight centerline over the barrel centerline
type WindInfo ¶
type WindInfo struct {
// contains filtered or unexported fields
}
WindInfo structure keeps information about wind
func AddWindInfo ¶
func AddWindInfo(untilRange unit.Distance, windVelocity unit.Velocity, direction unit.Angular) WindInfo
AddWindInfo creates description of one wind
func CreateNoWind ¶
func CreateNoWind() []WindInfo
CreateNoWind creates wind description with no wind
func CreateOnlyWindInfo ¶
CreateOnlyWindInfo creates the wind information for the constant wind for the whole distance of the shot
func CreateWindInfo ¶
CreateWindInfo creates a wind descriptor from multiple winds
winds must be ordered from the closest to the muzzlepoint to the farest to the muzzlepoint
func (WindInfo) Direction ¶
Direction returns the wind direction.
0 degrees means wind blowing into the face 90 degrees means wind blowing from the left -90 or 270 degrees means wind blowing from the right 180 degrees means wind blowing from the back
func (WindInfo) UntilDistance ¶
UntilDistance returns the distance from the shooter until which the wind blows
type ZeroInfo ¶
type ZeroInfo struct {
// contains filtered or unexported fields
}
ZeroInfo structure keeps the information about zeroing of the weapon
func CreateZeroInfo ¶
CreateZeroInfo creates zero information using distance only
func CreateZeroInfoWithAnotherAmmo ¶
func CreateZeroInfoWithAnotherAmmo(distance unit.Distance, ammo Ammunition) ZeroInfo
CreateZeroInfoWithAnotherAmmo creates zero information using distance and other ammunition
func CreateZeroInfoWithAnotherAmmoAndAtmosphere ¶
func CreateZeroInfoWithAnotherAmmoAndAtmosphere(distance unit.Distance, ammo Ammunition, atmosphere Atmosphere) ZeroInfo
CreateZeroInfoWithAnotherAmmoAndAtmosphere creates zero information using distance, other conditions and other ammunition
func CreateZeroInfoWithAtmosphere ¶
func CreateZeroInfoWithAtmosphere(distance unit.Distance, atmosphere Atmosphere) ZeroInfo
CreateZeroInfoWithAtmosphere creates zero information using distance and conditions
func (ZeroInfo) Ammunition ¶
func (v ZeroInfo) Ammunition() Ammunition
Ammunition return ammo used to zero
func (ZeroInfo) Atmosphere ¶
func (v ZeroInfo) Atmosphere() Atmosphere
Atmosphere returns conditions at the time of zeroing
func (ZeroInfo) HasAmmunition ¶
HasAmmunition return flag indicating whether other ammo is used to zero
func (ZeroInfo) HasAtmosphere ¶
HasAtmosphere returns flag indicating whether weapon is zeroed under different conditions
func (ZeroInfo) ZeroDistance ¶
ZeroDistance returns the distance at which the weapon was zeroed
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
unit
Package unit consists of the helper classes for all measurement unit that are used in trajectory calculation - e.g.
|
Package unit consists of the helper classes for all measurement unit that are used in trajectory calculation - e.g. |
|
vector
Package vector provides simple operations on 3d vector required for 3DF trajectory calculation
|
Package vector provides simple operations on 3d vector required for 3DF trajectory calculation |