ringpattern.h 586 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Ring Pattern header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_RINGSUPPORT_H
  10. #define DORAYME_RINGSUPPORT_H
  11. #include <pattern.h>
  12. class RingPattern : public Pattern
  13. {
  14. public:
  15. RingPattern(Colour a, Colour b) : Pattern(a, b) { };
  16. Colour patternAt(Tuple point)
  17. {
  18. double squared = (point.x * point.x) + (point.z * point.z);
  19. double value = floor(sqrt(squared));
  20. return (fmod(value, 2) == 0)?this->a:this->b;
  21. }
  22. };
  23. #endif /* DORAYME_RINGSUPPORT_H */