fmod is not mathematically valid. Replace it by a correct one.
This commit is contained in:
@@ -23,4 +23,9 @@ double max3(double a, double b, double c);
|
|||||||
|
|
||||||
double frand();
|
double frand();
|
||||||
|
|
||||||
|
static double modulo(double a, double b)
|
||||||
|
{
|
||||||
|
return a - floor(a/b) * b;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DORAYME_MATH_HELPER_H */
|
#endif /* DORAYME_MATH_HELPER_H */
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
{
|
{
|
||||||
double value = floor(point.x) + floor(point.y) + floor(point.z);
|
double value = floor(point.x) + floor(point.y) + floor(point.z);
|
||||||
|
|
||||||
return (fmod(value, 2) == 0)?this->a:this->b;
|
return (modulo(value, 2) == 0)?this->a:this->b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpMe(FILE *fp) {
|
void dumpMe(FILE *fp) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
|
|
||||||
double value = floor(sqrt(squared));
|
double value = floor(sqrt(squared));
|
||||||
|
|
||||||
return (fmod(value, 2) == 0)?this->a:this->b;
|
return (modulo(value, 2) == 0)?this->a:this->b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpMe(FILE *fp) {
|
void dumpMe(FILE *fp) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
|
|
||||||
Colour patternAt(Tuple point)
|
Colour patternAt(Tuple point)
|
||||||
{
|
{
|
||||||
if (fmod(floor(point.x), 2) == 0)
|
if (modulo(floor(point.x), 2) == 0)
|
||||||
{
|
{
|
||||||
return this->a;
|
return this->a;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
double u2 = floor(u * this->width);
|
double u2 = floor(u * this->width);
|
||||||
double v2 = floor(v * this->height);
|
double v2 = floor(v * this->height);
|
||||||
|
|
||||||
if (fmod((u2 + v2), 2) == 0)
|
if (modulo((u2 + v2), 2) == 0)
|
||||||
{
|
{
|
||||||
return this->a;
|
return this->a;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user