mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
5410a48a58
Co-authored-by: bofeng.song <bofeng.song@chukong-inc.com> Co-authored-by: dumganhar <dumganhar@gmail.com> Co-authored-by: mmyduckx <308303735@qq.com> Co-authored-by: Patrice Jiang <397136899@qq.com> Co-authored-by: 江战 <40414978+PatriceJiang@users.noreply.github.com>
31 lines
563 B
C++
31 lines
563 B
C++
#include "cocos/math/Utils.h"
|
|
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <random>
|
|
#include "math/Math.h"
|
|
|
|
namespace {
|
|
std::random_device rd;
|
|
std::uniform_real_distribution<float> uniformReal{0.0F, 1.0F};
|
|
} // namespace
|
|
|
|
namespace cc {
|
|
|
|
namespace mathutils {
|
|
|
|
float random() {
|
|
return uniformReal(rd);
|
|
}
|
|
|
|
Vec3ElementType absMaxComponent(const Vec3 &v) {
|
|
return absMax(absMax(v.x, v.y), v.z);
|
|
}
|
|
|
|
Vec3ElementType maxComponent(const Vec3 &v) {
|
|
return std::max(std::max(v.x, v.y), v.z);
|
|
}
|
|
|
|
} // namespace mathutils
|
|
|
|
} // namespace cc
|