You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ygradient.cpp 580B

1234567891011121314151617181920212223242526272829
  1. #include "terrain/ygradient.h"
  2. namespace vtk { namespace noise {
  3. YGradient::YGradient() {
  4. mStart = 0.0;
  5. mEnd = 0.0;
  6. }
  7. YGradient::YGradient(const double& start, const double& end) {
  8. mStart = start;
  9. mEnd = end;
  10. }
  11. void YGradient::setStart(const double& start) {
  12. mStart = start;
  13. }
  14. void YGradient::setEnd(const double& end) {
  15. mEnd = end;
  16. }
  17. double YGradient::get3D(const double& x, const double& y, const double& z) {
  18. double factor = (y - mStart) / (mEnd - mStart);
  19. if (factor >= 1.0) return 1.0;
  20. else if (factor <= 0.0) return -1.0;
  21. return (factor * 2.0) - 1.0;
  22. }
  23. }}