source: tests/vector_math/glm_equivalents/vec2_float.cc @ 474d610

arm-ehjacob/cs343-translationnew-ast-unique-expr
Last change on this file since 474d610 was 9b026f1, checked in by Thierry Delisle <tdelisle@…>, 23 months ago

Fixed name clash in test folder

  • Property mode set to 100644
File size: 767 bytes
Line 
1#include <glm/glm.hpp>
2#include <iostream>
3
4using namespace glm;
5
6std::ostream& operator<<(std::ostream& os, glm::tvec2<float>& v) {
7    os << "<" << v.x << "," << v.y << ">";
8    return os;
9}
10std::ostream& operator<<(std::ostream& os, glm::tvec2<float>&& v) {
11    os << "<" << v.x << "," << v.y << ">";
12    return os;
13}
14
15float length_squared(glm::tvec2<float> v) {
16    return glm::length(v) * glm::length(v);
17}
18
19tvec2<float> project(glm::tvec2<float> u, glm::tvec2<float> v) {
20    return normalize(v) * dot(u, normalize(v));
21}
22
23int 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.