Last change
on this file since 7a37fcb1 was
9b026f1,
checked in by Thierry Delisle <tdelisle@…>, 5 years ago
|
Fixed name clash in test folder
|
-
Property mode set to
100644
|
File size:
767 bytes
|
Rev | Line | |
---|
[9ec35db] | 1 | #include <glm/glm.hpp> |
---|
| 2 | #include <iostream> |
---|
| 3 | |
---|
| 4 | using namespace glm; |
---|
| 5 | |
---|
| 6 | std::ostream& operator<<(std::ostream& os, glm::tvec2<float>& v) { |
---|
| 7 | os << "<" << v.x << "," << v.y << ">"; |
---|
| 8 | return os; |
---|
| 9 | } |
---|
| 10 | std::ostream& operator<<(std::ostream& os, glm::tvec2<float>&& v) { |
---|
| 11 | os << "<" << v.x << "," << v.y << ">"; |
---|
| 12 | return os; |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | float length_squared(glm::tvec2<float> v) { |
---|
| 16 | return glm::length(v) * glm::length(v); |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | tvec2<float> project(glm::tvec2<float> u, glm::tvec2<float> v) { |
---|
| 20 | return normalize(v) * dot(u, normalize(v)); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | int main() { |
---|
| 24 | tvec2<float> v1 = {5.f,6.f}; |
---|
| 25 | tvec2<float> v2 = {0.f,-1.f}; |
---|
| 26 | std::cout << "refract:" << refract(v1,normalize(v2),1.f) << std::endl; |
---|
| 27 | std::cout << "refract:" << refract(v1,normalize(v2),1.f/1.33f) << std::endl; |
---|
| 28 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.