Celeritas 0.7.0-dev.251+develop.9b9328e4
Loading...
Searching...
No Matches
Functions
SenseUtils.hh File Reference

Sense helper functions and types. More...

#include "corecel/Macros.hh"
#include "OrangeTypes.hh"

Functions

constexpr Sense celeritas::to_sense (bool s)
 Convert a boolean value to a Sense enum.
 
constexpr Sense celeritas::flip_sense (Sense orig)
 Change the sense across a surface.
 
constexpr SignedSense celeritas::flip_sense (SignedSense orig)
 Change the sense across a surface.
 
constexpr SignedSense celeritas::real_to_sense (real_type quadric)
 Evaluate the sense based on the LHS expression of the quadric equation.
 
constexpr Sense celeritas::to_sense (SignedSense s)
 Convert a signed sense to a Sense enum.
 
constexpr SurfaceState celeritas::to_surface_state (SignedSense s)
 Convert a signed sense to a surface state.
 
constexpr char celeritas::to_char (Sense s)
 Get a printable character corresponding to a sense.
 
char constceleritas::to_cstring (SignedSense s)
 

Detailed Description

Sense helper functions and types.

Function Documentation

◆ real_to_sense()

constexpr SignedSense celeritas::real_to_sense ( real_type  quadric)
inlineconstexpr

Evaluate the sense based on the LHS expression of the quadric equation.

This is an optimized jump-free version of:

return quadric == 0 ? SignedSense::on
: quadric < 0 ? SignedSense::inside
: SignedSense::outside;

as

int gz = !(quadric <= 0) ? 1 : 0;
int lz = quadric < 0 ? 1 : 0;
return static_cast<SignedSense>(gz - lz);

and compressed into a single line.

NaN values are treated as "outside".