mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 23:50:27 +00:00
added area_auto and wvolarea_auto functions
This commit is contained in:
parent
af10592616
commit
0a6aae0776
@ -234,6 +234,7 @@ EX ld acos_auto(ld x) {
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief volume of a three-dimensional ball of radius r in the current isotropic geometry */
|
||||
EX ld volume_auto(ld r) {
|
||||
switch(cgclass) {
|
||||
case gcEuclid: return 4 * r * r * r / 3 * M_PI;
|
||||
@ -243,6 +244,22 @@ EX ld volume_auto(ld r) {
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief area of a circle of radius r in the current isotropic geometry */
|
||||
EX ld area_auto(ld r) {
|
||||
switch(cgclass) {
|
||||
case gcEuclid: return r * r * M_PI;
|
||||
case gcHyperbolic: return 2 * M_PI * (cosh(r) - 1);
|
||||
case gcSphere: return 2 * M_PI * (1 - cos(r));
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief volume in 3D, area in 2D */
|
||||
EX ld wvolarea_auto(ld r) {
|
||||
if(WDIM == 3) return volume_auto(r);
|
||||
else return area_auto(r);
|
||||
}
|
||||
|
||||
EX ld asin_clamp(ld x) { return x>1 ? M_PI/2 : x<-1 ? -M_PI/2 : std::isnan(x) ? 0 : asin(x); }
|
||||
|
||||
EX ld asin_auto_clamp(ld x) {
|
||||
|
Loading…
Reference in New Issue
Block a user