Skip to content

Commit

Permalink
[#17] : Added clamp function
Browse files Browse the repository at this point in the history
  • Loading branch information
ange-yaghi committed Jul 13, 2020
1 parent 87ac1b0 commit 667c060
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/yds_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ namespace ysMath {

ysVector ComponentMax(const ysVector &a, const ysVector &b);
ysVector ComponentMin(const ysVector &a, const ysVector &b);
ysVector Clamp(const ysVector &a, const ysVector &r_min, const ysVector &r_max);

ysVector MaxComponent(const ysVector &v);

Expand Down
7 changes: 7 additions & 0 deletions src/yds_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,13 @@ ysVector ysMath::ComponentMin(const ysVector &a, const ysVector &b) {
return result;
}

ysVector ysMath::Clamp(const ysVector &a, const ysVector &r_min, const ysVector &r_max) {
return ComponentMax(
ComponentMin(a, r_max),
r_min
);
}

ysVector ysMath::MaxComponent(const ysVector &v) {
// y, x, w, z
ysVector r1 = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 3, 0, 1));
Expand Down

0 comments on commit 667c060

Please sign in to comment.