载入中...
搜索中...
未找到
ForceMath.h
浏览该文件的文档.
1#pragma once
2
4
5#include <cmath>
6
8inline bool isFinite(double value) { return std::isfinite(value); }
9inline bool isFinite(ForceVector v) { return isFinite(v.x) && isFinite(v.y) && isFinite(v.z); }
10inline bool isNonnegative(double value) { return isFinite(value) && value >= 0; }
11inline bool isPositive(double value) { return isFinite(value) && value > 0; }
12inline ForceVector scale(ForceVector v, double s) { return {v.x * s, v.y * s, v.z * s}; }
13inline ForceVector add(ForceVector a, ForceVector b) { return {a.x + b.x, a.y + b.y, a.z + b.z}; }
14inline double dot(ForceVector a, ForceVector b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
15inline double length(ForceVector v) { return std::hypot(v.x, v.y, v.z); }
16template <class T>
19 "Invalid or overflowing physical model sample", "physics.forces"));
20}
22 if (!isFinite(value)) return invalid<ForceVector>();
24}
25} // namespace eve::physics::force_detail
const std::string & s
float v
float length
std::array< float, 3 > scale
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
Object::Ptr value
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
ForceVector add(ForceVector a, ForceVector b)
Definition ForceMath.h:13
bool isPositive(double value)
Definition ForceMath.h:11
bool isFinite(double value)
Definition ForceMath.h:8
bool isNonnegative(double value)
Definition ForceMath.h:10
Result< ForceVector > checked(ForceVector value)
Definition ForceMath.h:21
double dot(ForceVector a, ForceVector b)
Definition ForceMath.h:14
Owning world-space SI vector; 2D uses XY with Z exactly zero.
Definition ForceModels.h:12