28bool finite(
float v)
noexcept
30 return std::isfinite(
static_cast<double>(v));
39 return finite(v) && v > 0.0f;
49 switch (
object.type) {
52 object.width,
object.height,
object.value);
55 field.
addCircle(
object.centerX,
object.centerY,
56 object.radius,
object.value);
59 const float halfLength = 0.5f *
object.length;
60 field.
addBarrier(
object.centerX,
object.centerY - halfLength,
61 object.centerX,
object.centerY + halfLength,
62 object.thickness,
object.value);
67 object.centerY,
object.slitHeight,
object.value);
71 object.centerY,
object.slitSeparation,
72 object.slitHeight,
object.value);
75 const float halfWidth = 0.5f *
object.width;
76 const float halfHeight = 0.5f *
object.height;
77 const std::vector<PotentialPoint2D> vertices = {
78 {
object.centerX - halfWidth,
object.centerY},
79 {
object.centerX + halfWidth,
object.centerY - halfHeight},
80 {
object.centerX + halfWidth,
object.centerY + halfHeight}
87 object.sigmaX,
object.sigmaY,
object.value);
90 field.
addHarmonic(
object.centerX,
object.centerY,
object.value,
91 object.curvatureX,
object.curvatureY);
94 field.
addLinear(
object.centerX,
object.centerY,
object.value,
95 object.slopeX,
object.slopeY);
99 object.value,
object.softening);
103 object.width,
object.radius,
object.value);
147 const std::uint64_t
id =
nextId_++;
156 if (!
object.valid()) {
160 if (
object.
id == 0 ||
find(
object.
id) !=
nullptr) {
162 }
else if (
object.
id >=
nextId_) {
182 if (!replacement.
valid()) {
186 *existing = replacement;
192 const std::vector<PotentialObject2D>::iterator it =
226 if (
object.
id ==
id) {
236 if (
object.
id ==
id) {
246 if (target.
empty()) {
252 if (!
object.enabled || !
object.valid()) {
256 rasterizeObject(
object, scratch);
Implements the Potential Field2D component.
void addHarmonic(float centerX, float centerY, Value offset, float curvatureX, float curvatureY)
Adds harmonic.
std::size_t height() const noexcept
Returns height.
void addLinear(float centerX, float centerY, Value offset, float slopeX, float slopeY)
Adds linear.
void clear() noexcept
Performs clear.
void addPolygon(const std::vector< PotentialPoint2D > &vertices, Value value)
Adds polygon.
void addRectangle(float centerX, float centerY, float width, float height, Value value)
Adds rectangle.
float dy() const noexcept
Performs dy.
void addCircle(float centerX, float centerY, float radius, Value value)
Adds circle.
bool empty() const noexcept
Performs empty.
void addGaussian(float centerX, float centerY, float sigmaX, float sigmaY, Value amplitude)
Adds gaussian.
std::size_t width() const noexcept
Returns width.
float dx() const noexcept
Performs dx.
void addBarrier(float x1, float y1, float x2, float y2, float thickness, Value value)
Adds barrier.
void addStadiumExterior(float centerX, float centerY, float straightLength, float radius, Value value)
Adds stadium exterior.
void addSoftenedRadial(float centerX, float centerY, Value coupling, float softening)
Adds softened radial.
void accumulate(const PotentialField2D &other, Value scale=1.0f)
Performs accumulate.
void addDoubleSlit(float centerX, float barrierWidth, float slitCenterY, float slitSeparation, float slitHeight, Value value)
Adds double slit.
void addSingleSlit(float centerX, float barrierWidth, float slitCenterY, float slitHeight, Value value)
Adds single slit.
std::uint64_t add(PotentialObject2D object)
Performs add.
std::uint64_t allocateId() noexcept
Performs allocate id.
void rasterize(PotentialField2D &target) const
Performs rasterize.
std::vector< PotentialObject2D > objects_
std::size_t size() const noexcept
Returns size.
PotentialObject2D * find(std::uint64_t id) noexcept
Performs find.
bool empty() const noexcept
Performs empty.
bool update(std::uint64_t id, const PotentialObject2D &object)
Performs update.
bool remove(std::uint64_t id)
Performs remove.
const std::vector< PotentialObject2D > & objects() const noexcept
Performs objects.
void clear() noexcept
Performs clear.
void rasterizeObject(const PotentialObject2D &object, PotentialField2D &field)
Performs rasterize object.
bool positive(float v) noexcept
Performs positive.
Declares the potentialfield2d physics/numerical component used by QPE experiments.
Declares the potentialscene2d physics/numerical component used by QPE experiments.
Data structure used by the Potential Object2D component.
PotentialObjectType2D type
bool valid() const noexcept
Performs valid.