mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 01:00:25 +00:00
ldcoord as friends
This commit is contained in:
parent
b3fe4f102b
commit
7dc57d587a
16
crystal.cpp
16
crystal.cpp
@ -20,7 +20,14 @@ struct coord : public array<int, MAXDIM> {
|
||||
|
||||
static const coord c0 = {};
|
||||
|
||||
typedef array<ld, MAXDIM> ldcoord;
|
||||
struct ldcoord : public array<ld, MAXDIM> {
|
||||
friend ldcoord operator + (ldcoord a, ldcoord b) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[i] = a[i] + b[i]; return r; }
|
||||
friend ldcoord operator - (ldcoord a, ldcoord b) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[i] = a[i] - b[i]; return r; }
|
||||
friend ldcoord operator * (ldcoord a, ld v) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[i] = a[i] * v; return r; }
|
||||
friend ldcoord operator / (ldcoord a, ld v) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[i] = a[i] / v; return r; }
|
||||
friend ld operator | (ldcoord a, ldcoord b) { ld r=0; for(int i=0; i<MAXDIM; i++) r += a[i] * b[i]; return r; }
|
||||
};
|
||||
|
||||
static const ldcoord ldc0 = {};
|
||||
#endif
|
||||
|
||||
@ -46,13 +53,6 @@ ldcoord told(coord c) { ldcoord a; for(int i=0; i<MAXDIM; i++) a[i] = c[i]; retu
|
||||
// strange number to prevent weird acting in case of precision errors
|
||||
coord roundcoord(ldcoord c) { coord a; for(int i=0; i<MAXDIM; i++) a[i] = floor(c[i] + .5136); return a; }
|
||||
|
||||
ldcoord operator + (ldcoord a, ldcoord b) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[i] = a[i] + b[i]; return r; }
|
||||
ldcoord operator - (ldcoord a, ldcoord b) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[i] = a[i] - b[i]; return r; }
|
||||
ldcoord operator * (ldcoord a, ld v) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[i] = a[i] * v; return r; }
|
||||
ldcoord operator / (ldcoord a, ld v) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[i] = a[i] / v; return r; }
|
||||
|
||||
ld operator | (ldcoord a, ldcoord b) { ld r=0; for(int i=0; i<MAXDIM; i++) r += a[i] * b[i]; return r; }
|
||||
|
||||
EX ld compass_probability = 1;
|
||||
|
||||
int tocode(int cname) { return (1 << (cname >> 1)); }
|
||||
|
Loading…
Reference in New Issue
Block a user