# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>
#include <iostream>

int main() {
  // Ex1 moving point
  glm::vec3 p(1, 4, -5);
  glm::vec3 v(5, 1, 4);
  auto moved = p + v;
  std::cout << "EX1: " << glm::to_string(moved) << std::endl;

  // Ex2 adding vectors
  glm::vec3 result = glm::vec3(1, 0, 0) + glm::vec3(0, 1, 0);
  std::cout << "EX2: " << glm::to_string(result) << std::endl;

  // Ex4 mul by scalar
  glm::vec3 result2 = glm::vec3(0, 1, 0) * 5.0f;
  std::cout << "EX3: " << glm::to_string(result2) << std::endl;

  // Ex5 vec starting and ending
  glm::vec3 v2 = glm::vec3(1, -1, 4) - glm::vec3(8, 2, 5);
  std::cout << "EX4: " << glm::to_string(v2) << std::endl;

  // Ex6 normalize
  glm::vec3 result3 = glm::normalize(glm::vec3(1, 3, 4));
  std::cout << "EX5: " << glm::to_string(result3) << std::endl;

  return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <glm/glm.hpp>

#include <iostream>

#include <glm/gtx/string_cast.hpp>

int main(void)

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

glm::vec3 res = p + v;

std::cout << glm::to_string(res) << std::endl;

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

glm::vec3 v3 = v1 + v2;

std::cout << glm::to_string(v3) << std::endl;

glm::vec3 res2 = glm::vec3(0, 1, 0) * 5.0f;

std::cout << glm::to_string(res2) << std::endl;

glm::vec3 res3 = glm::vec3(1, -1, 4) - glm::vec3(8, 2, 5);

std::cout << glm::to_string(res3) << std::endl;

glm::vec3 res4 = glm::normalize(glm::vec3(1, 3, 4));

std::cout << glm::to_string(res4) << std::endl;

}

# data[].attributes.body
#include <iostream>

#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>

#define GLM_ENABLE_EXPERIMENTAL

int main(void)
{
    glm::vec3 p(1, 4, -5);
    glm::vec3 v(5, 1, 4);

    p += v;
    std::cout << "1. " << glm::to_string(p) << std::endl;

    glm::vec3 v1(1, 0, 0);
    glm::vec3 v2(0, 1, 0);

    glm::vec3 v3 = v1 + v2;

    std::cout << "2. " << glm::to_string(v3) << std::endl;

    v1 = glm::vec3(0, 1, 0);
    v1 *= 5;
    std::cout << "3. " << glm::to_string(v1) << std::endl;

    v = glm::vec3(1, -1, 4) - glm::vec3(8, 2, 5);
    std::cout << "4. " << glm::to_string(v) << std::endl;

    v = glm::normalize(glm::vec3(1, 3, 4));
    std::cout << "5. " << glm::to_string(v) << std::endl;

    return 0;
}

# data[].attributes.body
#define GLM_FORCE_SWIZZLE

#define GLM_ENABLE_EXPERIMENTAL

#include "CMakeProject1.h"

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

using namespace std;

int main()

{

//class notes

//glm::vec3 a(1, 3, 4);

//glm::vec2 b(3, 4);

//a = a * 3.0f;

//a = 3.0f * a;

//float l = glm::length(a);

//a = glm::normalize(a); //ok

////a.normalizea(); //error

//a.xy = b.xx; //ok

//return 0;

//practice exercise 1:

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

glm::vec3 res1 = p + v;

std::cout << "Exercise 1: " << glm::to_string(res1) << std::endl;

//practice exercise 2:

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

glm::vec3 res2 = v1 + v2;

std::cout << "Exercise 2: " << glm::to_string(res2) << std::endl;

//practice exercise 3:

glm::vec3 v3(0, 1, 0);

glm::vec3 res3 = v3 * 5.0f;

std::cout << "Exercise 3: " << glm::to_string(res3) << std::endl;

//practice exercise 4:

glm::vec3 v4(8, 2, 5);

glm::vec3 v5(1, -1, 4);

glm::vec3 res4 = v5 - v4;

std::cout << "Exercise 4: " << glm::to_string(res4) << std::endl;

//practice exercise 5:

glm::vec3 v6(1, 3, 4);

glm::vec3 res5 = glm::normalize(v6);

std::cout << "Exercise 5: " << glm::to_string(res5) << std::endl;

return 0;

}

# data[].attributes.body
#include <glm/glm.hpp>

#include <iostream>

#include <glm/gtx/string_cast.hpp>

void exercice1() {

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

glm::vec3 res = p + v;

std::cout << glm::to_string(res) << std::endl;

}

void exercice2() {

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

glm::vec3 res = v1 + v2;

std::cout << glm::to_string(res) << std::endl;

}

void exercice3() {

float scalar = 5.0f;

glm::vec3 v1(0, 1, 0);

glm::vec3 res = v1 * scalar;

std::cout << glm::to_string(res) << std::endl;

}

void exercice4() {

glm::vec3 v(8, 2, 5);

glm::vec3 v2(1, -1, 4);

glm::vec3 res = v2 - v;

std::cout << glm::to_string(res) << std::endl;

}

void exercice5() {

glm::vec3 v(1, 3, 4);

glm::vec3 res = glm::normalize(v);

std::cout << glm::to_string(res) << std::endl;

}

int main() {

//Exercice 1

std::cout << "Exercice 1 :" << std::endl;

exercice1();

//Exercice 2

std::cout << "Exercice 2 :" << std::endl;

exercice2();

//Exercice 3

std::cout << "Exercice 3 :" << std::endl;

exercice3();

//Exercice 4

std::cout << "Exercice 4 :" << std::endl;

exercice4();

//Exercice 5

std::cout << "Exercice 5 :" << std::endl;

exercice5();

return 0;

}

# data[].attributes.body
// CMakeProject2.cpp : définit le point d'entrée de l'application.

//

#define GLM_ENABLE_EXPERIMENTAL

#define GLM_FORCE_SWIZZLE

#include "glm/gtx/string_cast.hpp"

#include "CMakeProject2.h"

#include "glm/glm.hpp"

using namespace std;

int main()

{

// EX1

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

std::cout << "Ex1: " << glm::to_string(p + v) << std::endl;

// EX2

{

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

std::cout << "Ex2: " << glm::to_string(v1 + v2) << std::endl;

}

// EX3

{

glm::vec3 v1(0, 1, 0);

v1 = v1 * 5.0f;

std::cout << "Ex3: " << glm::to_string(v1) << std::endl;

}

// EX4

{

glm::vec3 v1(8, 2, 5);

glm::vec3 v2(1, -1, 4);

glm::vec3 v = v2 - v1;

std::cout << "Ex4: " << glm::to_string(v) << std::endl;

}

//EX5

{

glm::vec3 v(1, 3, 4);

v = glm::normalize(v);

std::cout << "Ex5: " << glm::to_string(v) << std::endl;

}

return 0;

}

Ex1: vec3(6.000000, 5.000000, -1.000000)

Ex2: vec3(1.000000, 1.000000, 0.000000)

Ex3: vec3(0.000000, 5.000000, 0.000000)

Ex4: vec3(-7.000000, -3.000000, -1.000000) Ex5: vec3(0.196116, 0.588348, 0.784465)

# data[].attributes.body
#define GLM_FORCE_SWIZZLE

#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

//Exercice 1

static glm::vec3 FirstEx() {

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

p = p + v;

return p;

}

//Exercice 2

static glm::vec3 SecondEx() {

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

return v1 + v2;

}

//Exercice 3

static glm::vec3 ThirdEx() {

glm::vec3 v1(0, 1, 0);

v1 = v1 * 5.0f;

return v1;

}

//Exercice 4

static glm::vec3 FourthEx() {

glm::vec3 v(-7, -3, -1);

return v;

}

//Exercice 5

static glm::vec3 FifthEx() {

glm::vec3 v(1, 3, 4);

v = glm::normalize(v);

return v;

}

int main() {

std::cout << glm::to_string(FirstEx()) << std::endl;

std::cout << glm::to_string(SecondEx()) << std::endl;

std::cout << glm::to_string(ThirdEx()) << std::endl;

std::cout << glm::to_string(FourthEx()) << std::endl;

std::cout << glm::to_string(FifthEx()) << std::endl;

return 0;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/vec3.hpp>
#include <glm/common.hpp>
#include <glm/gtx/string_cast.hpp>
#include <iostream>

static void exercice1()
{
	glm::vec3 p(1, 4, -5);
	glm::vec3 v(5, 1, 4);

	p += v;
	std::cout << glm::to_string(p) << std::endl;
}

static void exercice2()
{
	glm::vec3 v1(1, 0, 0);
	glm::vec3 v2(0, 1, 0);

	glm::vec3 v3 = v1 + v2;
	std::cout << glm::to_string(v3) << std::endl;
}

static void exercice3()
{
	glm::vec3 v1(0, 1, 0);

	v1 *= 5;
	std::cout << glm::to_string(v1) << std::endl;
}

static void exercice4()
{
	glm::vec3 p1(8, 2, 5);
	glm::vec3 p2(1, -1, 4);
	glm::vec3 v = p2 - p1;
	std::cout << glm::to_string(v) << std::endl;
}

static void exercice5()
{
	glm::vec3 v(1, 3, 4);

	v = glm::normalize(v);
	std::cout << glm::to_string(v) << std::endl;
}

int main(int argc, char** argv)
{
	std::cout << "Exercice 1: ";
	exercice1();
	std::cout << "Exercice 2: ";
	exercice2();
	std::cout << "Exercice 3: ";
	exercice3();
	std::cout << "Exercice 4: ";
	exercice4();
	std::cout << "Exercice 5: ";
	exercice5();
	return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include "CMake_wxWidgets_openGL.h"
#include <glm/gtx/string_cast.hpp>
#include <glm/glm.hpp>

using namespace std;

// First exercice:
void movePointByVector(glm::vec3 point, glm::vec3 vector)
{
	point += vector;
}

// Second exercice:
void addVector(glm::vec3 source, glm::vec3 other)
{
	source += other;
}

// Third exercice:
void multiplyVector(glm::vec3 source, int scalar)
{
	source *= scalar;
}

// Fourth exercice:
glm::vec3 getVector(glm::vec3 p1, glm::vec3 p2)
{
	return p2 - p1;
}

// Fifth exercice:
glm::vec3 normalizeVector(glm::vec3 vector)
{
	return glm::normalize(vector);
}

int main()
{
	movePointByVector({ 1,4,-5 }, { 5,1,4 });
	addVector({ 1, 0, 0 }, { 0, 1, 0 });
	multiplyVector({ 0, 1, 0 }, 5);
	getVector({ 8,2,5 }, { 1,-1,4 });
	normalizeVector({ 1,3,4 });

	return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include "CMake_wxWidgets_openGL.h"
#include <glm/gtx/string_cast.hpp>
#include <glm/glm.hpp>

using namespace std;

// First exercice:
void movePointByVector(glm::vec3 point, glm::vec3 vector)
{
	point += vector;
	std::cout << "Ex01: " << glm::to_string(point) << std::endl;
}

// Second exercice:
void addVector(glm::vec3 source, glm::vec3 other)
{
	source += other;
	std::cout << "Ex02: " << glm::to_string(source) << std::endl;
}

// Third exercice:
void multiplyVector(glm::vec3 source, int scalar)
{
	source *= scalar;
	std::cout << "Ex03: " << glm::to_string(source) << std::endl;
}

// Fourth exercice:
glm::vec3 getVector(glm::vec3 p1, glm::vec3 p2)
{
	std::cout << "Ex04: " << glm::to_string(p2 - p1) << std::endl;
	return p2 - p1;
}

// Fifth exercice:
glm::vec3 normalizeVector(glm::vec3 vector)
{
	std::cout << "Ex05: " << glm::to_string(glm::normalize(vector)) << std::endl;
	return glm::normalize(vector);
}

int main()
{
	movePointByVector({ 1,4,-5 }, { 5,1,4 });
	addVector({ 1, 0, 0 }, { 0, 1, 0 });
	multiplyVector({ 0, 1, 0 }, 5);
	getVector({ 8,2,5 }, { 1,-1,4 });
	normalizeVector({ 1,3,4 });

	return 0;
}


//	Results:
//	Ex01: vec3(6.000000, 5.000000, -1.000000)
//	Ex02: vec3(1.000000, 1.000000, 0.000000)
//	Ex03: vec3(0.000000, 5.000000, 0.000000)
//	Ex04: vec3(-7.000000, -3.000000, -1.000000)
//	Ex05: vec3(0.196116, 0.588348, 0.784465)

# data[].attributes.body
#include <iostream>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>

void ex1()
{
    constexpr glm::vec3 p(1, 4, -5);
    constexpr glm::vec3 v(5, 1, 4);
    glm::vec3 result(0, 0, 0);

    result = p + v;

    std::cout << "Result: " << glm::to_string(result) << std::endl;
}

void ex2()
{
    constexpr glm::vec3 v1(1, 0, 0);
    constexpr glm::vec3 v2(0, 1, 0);

    glm::vec3 result(0, 0, 0);
    result = v1 + v2;

    std::cout << "Result: " << glm::to_string(result) << std::endl;
}

void ex3()
{
    constexpr glm::vec3 v1(0, 1, 0);

    glm::vec3 result(0, 0, 0);
    result = v1 * 5.0f;

    std::cout << "Result: " << glm::to_string(result) << std::endl;
}

void ex4()
{
    constexpr glm::vec3 p1(8, 2, 5);
    constexpr glm::vec3 p2(1, -1, 4);

    glm::vec3 result(0, 0, 0);
    result = p2 - p1;

    std::cout << "Result: " << glm::to_string(result) << std::endl;
}

void ex5()
{
    constexpr glm::vec3 v(1, 3, 4);
    glm::vec3 result(0, 0, 0);

    result = glm::normalize(v);

    std::cout << "Result: " << glm::to_string(result) << std::endl;
}

int main()
{
    ex1();
    ex2();
    ex3();
    ex4();
    ex5();
    return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

int main() {

std::cout << "1. Move Point p(1,4,-5) by vector v(5,1,4)" << std::endl;

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

p += v;

std::cout << "Result: " << glm::to_string(p) << "\n" << std::endl;

std::cout << "2. Add vector v1(1,0,0) and vector v2(0,1,0)" << std::endl;

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

glm::vec3 result = v1 + v2;

std::cout << "Result: " << glm::to_string(result) <<"\n" << std::endl;

std::cout << "3. Multiply v1(0,1,0) with scalar 5" << std::endl;

v1 = glm::vec3(0, 1, 0);

v1 *= 5.0f;

std::cout << "Result: " << glm::to_string(v1) << "\n" << std::endl;

std::cout << "4. Get a vector v starting at (8,2,5) and ending at (1,-1,4)" << std::endl;

glm::vec3 vstart(8, 2, 5);

glm::vec3 vend(1, -1, 4);

result = vend - vstart;

std::cout << "Result: " << glm::to_string(result) << "\n" << std::endl;

std::cout << "5. Normalize vector v(1,3,4)" << std::endl;

v = glm::normalize(glm::vec3(1, 3, 4));

std::cout << "Result: " << glm::to_string(v) << std::endl;

return 0;

}

# data[].attributes.body
#include <iostream>

#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>

#define GLM_ENABLE_EXPERIMENTAL

int main(void)
{
    glm::vec3 p(1, 4, -5);
    glm::vec3 v(5, 1, 4);

    p += v;
    std::cout << "1. " << glm::to_string(p) << std::endl;

    glm::vec3 v1(1, 0, 0);
    glm::vec3 v2(0, 1, 0);

    glm::vec3 v3 = v1 + v2;

    std::cout << "2. " << glm::to_string(v3) << std::endl;

    v1 = glm::vec3(0, 1, 0);
    v1 *= 5;
    std::cout << "3. " << glm::to_string(v1) << std::endl;

    v = glm::vec3(1, -1, 4) - glm::vec3(8, 2, 5);
    std::cout << "4. " << glm::to_string(v) << std::endl;

    v = glm::normalize(glm::vec3(1, 3, 4));
    std::cout << "5. " << glm::to_string(v) << std::endl;

    return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

void movePPoint()

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

p += v;

std::cout << glm::to_string(p) << std::endl;

}

void AddV1Vector()

{

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

v1 += v2;

std::cout << glm::to_string(v1) << std::endl;

}

void MultiplyV1Vector()

{

glm::vec3 v1(0, 1, 0);

v1 *= 5.0f;

std::cout << glm::to_string(v1) << std::endl;

}

void GetV1Vector()

{

glm::vec3 start(8, 2, 5);

glm::vec3 ending(1, -1, 4);

glm::vec3 v;

v = ending - start;

std::cout << glm::to_string(v) << std::endl;

}

void NormalizeVector()

{

glm::vec3 v(1, 3, 4);

v = glm::normalize(v);

std::cout << glm::to_string(v) << std::endl;

}

int main()

{

movePPoint();

AddV1Vector();

MultiplyV1Vector();

GetV1Vector();

NormalizeVector();

return 0;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <glm/gtx/string_cast.hpp>

#include <iostream>

static void exonb1()

{

glm::vec3 p(1.0f, 4.0f, 5.0f);

glm::vec3 v(5.0f, 1.0f, 4.0f);

std::cout << "Q1. Move Point p(1,4, 5) by vector v(5,1,4).\n" << "result: "

<< glm::to_string(p + v) << std::endl;

}

static void exonb2()

{

glm::vec3 v1(1.0f, 0.0f, 0.0f);

glm::vec3 v2(0.0f, 1.0f, 0.0f);

std::cout << "Q2. Add vector v1(1,0,0) and vector v2(0,1,0)\n" << "result: "

<< glm::to_string(v1 + v2) << std::endl;

}

static void exonb3()

{

glm::vec3 v1(0.0f, 1.0f, 0.0f);

std::cout << "Q3. Multiply v1(0,1,0) with scalar 5.\n" << "result: "

<< glm::to_string(v1 * 5.0f) << std::endl;

}

static void exonb4()

{

glm::vec3 start(8.0f, 2.0f, 5.0f);

glm::vec3 end(1.0f, -1.0f, 4.0f);

std::cout << "Q4. Get a vector v starting at (8,2,5) and ending at (1,-1,4)\n"

<< "result: " << glm::to_string(end - start) << std::endl;

}

static void exonb5()

{

glm::vec3 v(1.0f, 3.0f, 4.0f);

std::cout << "Q5. Normalize vector v(1,3,4).\n" << "result: "

<< glm::to_string(glm::normalize(v)) << std::endl;

}

int main()

{

exonb1();

exonb2();

exonb3();

exonb4();

exonb5();

return 0;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <glm/glm.hpp>

#include <iostream>

#include <glm/vec3.hpp>

#include <glm/gtx/string_cast.hpp>

glm::vec3 exercice01() {

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

return (p + v);

}

glm::vec3 exercice02() {

glm::vec3 p(1, 0, 0);

glm::vec3 v(0, 1, 0);

return (p + v);

}

glm::vec3 exercice03() {

glm::vec3 v1(0, 1, 0);

return (v1 * 5.0f);

}

glm::vec3 exercice04() {

glm::vec3 start(8, 2, 5);

glm::vec3 end(1, -1, 4);

return (end - start);

}

glm::vec3 exercice05() {

glm::vec3 v(1, 3, 4);

return glm::normalize(v);

}

int main() {

std::cout << "Exercice 01: " << glm::to_string(exercice01()) << std::endl;

std::cout << "Exercice 02: " << glm::to_string(exercice02()) << std::endl;

std::cout << "Exercice 03: " << glm::to_string(exercice03()) << std::endl;

std::cout << "Exercice 04: " << glm::to_string(exercice04()) << std::endl;

std::cout << "Exercice 05: " << glm::to_string(exercice05()) << std::endl;

return 0;

}

# data[].attributes.body
#include <iostream>
#include <glm/glm.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include  <glm/gtx/string_cast.hpp>

int main() {
	glm::vec3 p(1, 4, -5);
	glm::vec3 v1(1, 0, 0), v2(0, 1, 0);
	glm::vec3 vStart(1, -1, 4);
	glm::vec3 vEnd(8, 2, 5);

	std::cout << "p moved by (5,1,4) : \t\t\t\t\t" << glm::to_string(p + glm::vec3(5, 1, 4)) << std::endl;
	std::cout << "v1 + v2 : \t\t\t\t\t\t" << glm::to_string(v1 + v2) << std::endl;
	std::cout << "Multiply v1(0,1,0) with  scalar 5 : \t\t\t" << glm::to_string(glm::vec3(0, 1, 0) * 5.0f) << std::endl;
	std::cout << "v Starting at  (8,2,5) and ending at (1,-1,4) : \t" << glm::to_string(vEnd - vStart) << std::endl;
	std::cout << "Normalized (1,3,4) : \t\t\t\t\t" << glm::to_string(glm::normalize(glm::vec3(1, 3, 4))) << std::endl;

	return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

glm::vec3 MovePoint(glm::vec3 p, glm::vec3 v) {

p += v;

return p;

}

glm::vec3 AddVector(glm::vec3 v1, glm::vec3 v2) {

return v1 + v2;

}

glm::vec3 MultiplyVector(glm::vec3 v, float scalar) {

v = v * scalar;

return v;

}

glm::vec3 GetVector(glm::vec3 starting, glm::vec3 ending) {

return ending - starting;

}

glm::vec3 NormalizeVector(glm::vec3 v) {

return glm::normalize(v);

}

int main() {

std::cout << "Exercice 1:" << std::endl;

glm::vec3 p(1,4,-5);

glm::vec3 v(5, 1, 4);

std::cout << "Move Point p(1, 4, -5) by vector v(5, 1, 4): " << glm::to_string(MovePoint(p, v)) << std::endl;

std::cout << "Exercice 2:" << std::endl;

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 2, 0);

std::cout << "Add vector v1(1, 0, 0) and vector v2(0, 1, 0): " << glm::to_string(AddVector(v1, v2)) << std::endl;

std::cout << "Exercice 3:" << std::endl;

v1 = glm::vec3(0, 1, 0);

std::cout << "Multiply v1(0, 1, 0) with scalar 5: " << glm::to_string(MultiplyVector(v1, 5)) << std::endl;

std::cout << "Exercice 4:" << std::endl;

v1 = glm::vec3(8, 2, 5);

v2 = glm::vec3(1, -1, 4);

std::cout << "Get a Vector v starting at (8, 2, 5) and ending at (1, -1, 5): " << glm::to_string(GetVector(v1, v2)) << std::endl;

std::cout << "Exercice 5:" << std::endl;

v = glm::vec3(1, 3, 4);

std::cout << "Normalize vector v(1, 3, 4): " << glm::to_string(NormalizeVector(v)) << std::endl;

return 0;

}

# data[].attributes.body
#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>
#include <GLFW/glfw3.h>
#include <iostream>

#define GLM_ENABLE_EXPERIMENTAL

glm::vec3 getVector(glm::vec3 startPoint, glm::vec3 endPoint)
{
    return endPoint - startPoint;
}

int main(int ac, char** av)
{
    auto p = glm::vec3(1, 4, -5);
    auto v = glm::vec3(5, 1, 4);

    p += v;
    std::cout << "1) p + v: " << glm::to_string(p) << std::endl;

    auto v1 = glm::vec3(1,0,0);
    auto v2 = glm::vec3(0,1,0);

    std::cout << "2) v1 + v2: " << glm::to_string(v1 + v2) << std::endl;

    v1 = glm::vec3(0, 1, 0);
    v1 *= 5;
    std::cout << "3) v * 5: " << glm::to_string(v1) << std::endl;

    v = getVector(glm::vec3(8, 2, 5), glm::vec3(1, -1, 4));
    std::cout << "4) v: " << glm::to_string(v) << std::endl;

    v = glm::vec3(1, 3, 4);
    v = glm::normalize(v);
    std::cout << "5) v (normalized):" << glm::to_string(v) << std::endl;

    return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

void movePointToVector(void) // Ex 1

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

std::cout << "[*] Exercice 1: Move the point p(1, 4, -5) by vector v(5, 1, 4) " << std::endl;

std::cout << "Result: " << glm::to_string(p + v) << std::endl;

}

void addTwoVector(void) // Ex 2

{

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

std::cout << "[*] Exercice 2: Add Vector v1(1, 0, 0) and vector v2(0, 1, 0)" << std::endl;

std::cout << "Result: " << glm::to_string(v1 + v2) << std::endl;

}

void multiplyVectorWithScalar(void)

{

glm::vec3 v1(0, 1, 0);

float scalar = 5.f;

std::cout << "[*] Exercice 3: Multiply v1(0, 1, 0) with scalar 5" << std::endl;

std::cout << "Result: " << glm::to_string(v1 * scalar) << std::endl;

}

void getVectorLength(void)

{

glm::vec3 startPoint(8, 2, 5);

glm::vec3 endPoint(1, -1, 4);

glm::vec3 v(startPoint - endPoint);

std::cout << "[*] Exercice 4: Get a vector v starting at (8, 2, 5) and ending at (1, -1, 4)" << std::endl;

std::cout << "Result: " << glm::to_string(v) << std::endl;

}

void normalizeVector(void)

{

glm::vec3 v(1, 3, 4);

std::cout << "[*] Exercice 5: Normalize vector v(1, 3, 4)" << std::endl;

std::cout << "Result: " << glm::to_string(glm::normalize(v)) << std::endl;

}

int main(void)

{

movePointToVector();

std::cout << std::endl;

addTwoVector();

std::cout << std::endl;

multiplyVectorWithScalar();

std::cout << std::endl;

getVectorLength();

std::cout << std::endl;

normalizeVector();

return 0;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#define GLM_FORCE_SWIZZLE

#include <iostream>

#include "glm/glm.hpp"

#include "glm/gtx/string_cast.hpp"

int MovePoint()

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

p += v;

std::cout << "1. " << glm::to_string(p) << std::endl;

return 0;

}

int AddVector()

{

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

std::cout << "2. " << glm::to_string(v1 + v2) << std::endl;

return 0;

}

int Multiply()

{

glm::vec3 v1(0, 1, 0);

std::cout << "3. " << glm::to_string(v1 * 5.f) << std::endl;

return 0;

}

int VectorStartEnd()

{

glm::vec3 vStart(8, 2, 5);

glm::vec3 vEnd(1, -1, 4);

std::cout << "4. " << glm::to_string(vEnd - vStart) << std::endl;

return 0;

}

int Normalize()

{

glm::vec3 v(1, 3, 4);

std::cout << "5. " << glm::to_string(glm::normalize(v)) << std::endl;

return 0;

}

int main()

{

MovePoint();

AddVector();

Multiply();

VectorStartEnd();

Normalize();

return 0;

}

# data[].attributes.body
#include <iostream>
#include <glm/vec3.hpp>
#include <glm/gtx/string_cast.hpp>

#define GLM_ENABLE_EXPERIMENTAL

int main() {
    std::cout << "practice GLM" << std::endl;
    glm::vec3 p(1,4,-5);
    glm::vec3 v(5,1,4);
    glm::vec3 v1(1,0,0);
    glm::vec3 v2(0,1,0);
    glm::vec3 vSca(0,1,0);
    glm::vec3 vStart(8,2,5);
    glm::vec3 vEnd(1,-1,4);

   std::cout << "ex 1: point = " << glm::to_string((p + v)) << std::endl;
    std::cout << "ex 2: new vector = " << glm::to_string((v1 + v2)) << std::endl;
    std::cout << "ex 3: mul vec = " << glm::to_string((vSca * 5.f)) << std::endl;
    std::cout << "ex 4: vector = " << glm::to_string(vEnd - vStart) << std::endl;
    std::cout << "ex 5: normalize = " << glm::to_string(glm::normalize(glm::vec3(1,3,4)));
    return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include "CMakeProject1.h"

#include <glm/vec3.hpp>

#include <glm/gtx/string_cast.hpp>

int main()

{

glm::vec3 p{ 1, 4, -5 };

glm::vec3 v{ 5, 1, 4 };

p = p + v;

std::cout << "1/ " << glm::to_string(p) << '\n';

glm::vec3 v1{ 1, 0, 0 };

glm::vec3 v2{ 0, 1, 0 };

glm::vec3 result{ v1 + v2 };

std::cout << "2/ " << glm::to_string(result) << '\n';

std::cout << "3/ " << glm::to_string(v2 * 5.0f) << '\n';

glm::vec3 v_new{ 1 - 8, -1 - 2, 4 - 5 };

std::cout << "4/ " << glm::to_string(v) << '\n';

glm::vec3 norm_v_new = glm::normalize(glm::vec3 {1, 3, 4});

std::cout << "5/ " << glm::to_string(norm_v_new) << '\n';

return 0;

}

# data[].attributes.body
#include <iostream>

#include <glm/glm.hpp>

# define GLM_ENABLE_EXPERIMENTAL

#include <glm/gtx/string_cast.hpp>

using namespace std;

glm::vec3 ex1()

{

glm::vec3 v = glm::vec3(5, 1, 4);

glm::vec3 p = glm::vec3(1, 4, -5);

p += v;

return p;

}

glm::vec3 ex2()

{

glm::vec3 v1 = glm::vec3(1, 0, 0);

glm::vec3 v2 = glm::vec3(0, 1, 0);

glm::vec3 result = v1 + v2;

return result;

}

glm::vec3 ex3()

{

glm::vec3 v1 = glm::vec3(0, 1, 0);

v1 = v1 * 5.0f;

return v1;

}

glm::vec3 ex4()

{

glm::vec3 startPoint = glm::vec3(8, 2, 5);

glm::vec3 endPoint = glm::vec3(1, -1, 4);

glm::vec3 vector = endPoint - startPoint;

return vector;

}

glm::vec3 ex5()

{

glm::vec3 v = glm::vec3(1, 3, 4);

glm::vec3 v_h = glm::normalize(v);

return v_h;

}

int main()

{

// 1. Move Point p(1, 4, -5) by vector v(5, 1, 4).

cout << glm::to_string(ex1()) << endl;

// 2. Add vector v1(1, 0, 0) and vector v2(0, 1, 0)

cout << glm::to_string(ex2()) << endl;

//3. Multiply v1(0, 1, 0) with scalar 5.

cout << glm::to_string(ex3()) << endl;

//4. Get a vector v starting at(8, 2, 5) and ending at(1, -1, 4)

cout << glm::to_string(ex4()) << endl;

//5. Normalize vector v(1, 3, 4).

cout << glm::to_string(ex5()) << endl;

return 0;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <glm/glm.hpp>

#include <iostream>

#include <glm/gtx/string_cast.hpp>

int main(void)

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

glm::vec3 res = p - v;

std::cout << glm::to_string(res) << std::endl;

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

glm::vec3 v3 = v1 + v2;

std::cout << glm::to_string(v3) << std::endl;

glm::vec3 res2 = glm::vec3(0, 1, 0) * 5.0f;

std::cout << glm::to_string(res2) << std::endl;

glm::vec3 res3 = glm::vec3(1, -1, 4) - glm::vec3(8, 2, 5);

std::cout << glm::to_string(res3) << std::endl;

glm::vec3 res4 = glm::normalize(glm::vec3(1, 3, 4));

std::cout << glm::to_string(res4) << std::endl;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

#include <iostream>

glm::vec3 MovePoint()

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

p += v;

return p;

}

glm::vec3 AddVectors()

{

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

v1 += v2;

return v1;

}

glm::vec3 ScaleVector()

{

glm::vec3 v1(0, 1, 0);

v1 *= 5;

return v1;

}

glm::vec3 GetVector()

{

glm::vec3 p(8, 2, 5);

glm::vec3 q(1, -1, 4);

glm::vec3 v = q - p;

return v;

}

glm::vec3 NormalizeVector()

{

glm::vec3 v1(1, 3, 4);

return glm::normalize(v1);

}

int main()

{

std::cout << "MovePoint: " << glm::to_string(MovePoint()) << std::endl;

std::cout << "AddVectors: " << glm::to_string(AddVectors()) << std::endl;

std::cout << "ScaleVector: " << glm::to_string(ScaleVector()) << std::endl;

std::cout << "GetVector: " << glm::to_string(GetVector()) << std::endl;

std::cout << "NormalizeVector: " << glm::to_string(NormalizeVector()) << std::endl;

return 0;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/vec3.hpp>
#include <glm/gtx/string_cast.hpp>

static void ex1() {
	glm::vec3 p(1.0f, 4.0f, -5.0f);
	glm::vec3 v(5.0f, 1.0f, 4.0f);
	p += v;
	std::cout << "exercice 1: " << glm::to_string(p) << std::endl;
}

static void ex2() {
	glm::vec3 v1(1.0f, 0.0f, 0.0f);
	glm::vec3 v2(0.0f, 1.0f, 0.0f);
	glm::vec3 result = v1 + v2;
	std::cout << "exercice 2: " << glm::to_string(result) << std::endl;
}

static void ex3() {
	glm::vec3 v1(0.0f, 1.0f, 0.0f);
	glm::vec3 result = v1 * 5.0f;
	std::cout << "exercice 3: " << glm::to_string(result) << std::endl;
}

static void ex4() {
	glm::vec3 begin(8.0f, 2.0f, 5.0f);
	glm::vec3 end(1.0f, -1.0f, 4.0f);
	glm::vec3 result = end - begin;
	std::cout << "exercice 4: " << glm::to_string(result) << std::endl;
}

static void ex5() {
	glm::vec3 v(1.0f, 3.0f, 4.0f);
	glm::vec3 result = glm::normalize(v);
	std::cout << "exercice 5: " << glm::to_string(result) << std::endl;
}

int main() {
	ex1();
	ex2();
	ex3();
	ex4();
	ex5();
	return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <glm/vec3.hpp>
#include <glm/gtx/string_cast.hpp>
#include <iostream>

static void exercise1()
{
	glm::vec3 p(1, 4, -5);
	glm::vec3 v(5, 1, 4);

	p += v;
	std::cout << glm::to_string(p) << std::endl;
}

static void exercise2()
{
	glm::vec3 v1(1, 0, 0);
	glm::vec3 v2(0, 1, 0);
	glm::vec3 res = v1 + v2;

	std::cout << glm::to_string(res) << std::endl;
}

static void exercise3()
{
	glm::vec3 v1(0, 1, 0);
	glm::vec3 res = v1 * 5.0f;

	std::cout << glm::to_string(res) << std::endl;
}

static void exercise4()
{
	glm::vec3 start(8, 2, 5);
	glm::vec3 end(1, -1, 4);
	glm::vec3 v = end - start;

	std::cout << glm::to_string(v) << std::endl;
}

static void exercise5()
{
	glm::vec3 v(1, 3, 4);
	glm::vec3 res = glm::normalize(v);

	std::cout << glm::to_string(res) << std::endl;
}

int main()
{
	exercise1();
	exercise2();
	exercise3();
	exercise4();
	exercise5();
	return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL
#include "CMakeProject1.h"
#include "iostream"
#include "glm/vec3.hpp"
#include "glm/glm.hpp"
#include "glm/gtx/string_cast.hpp"

using namespace std;

int main()
{
	const auto p2 = glm::vec3(1, 4, -5) + glm::vec3(5, 1, 4);
	std::cout << "1. Move Point p(1, 4, -5) by vector v(5, 1, 4) = " << glm::to_string(p2) << std::endl;

	const auto v2a = glm::vec3(1, 0, 0) + glm::vec3(0, 1, 0);
	std::cout << "2. Add vector v1(1, 0, 0) and vector v2(0, 1, 0) = " << glm::to_string(v2a) << std::endl;

	const auto v2b = glm::vec3(0, 1, 0) * 5.f;
	std::cout << "3. Multiply v1(0, 1, 0) with scalar 5 = " << glm::to_string(v2b) << std::endl;

	const auto v = glm::vec3(1, -1, 4) - glm::vec3(8, 2, 5);
	std::cout << "4. Get a vector v starting at(8, 2, 5) and ending at(1, -1, 4) = " << glm::to_string(v) << std::endl;

	const auto v2c = glm::normalize(glm::vec3(1, 3, 4));
	std::cout << "5. Normalize vector v(1, 3, 4) = " << glm::to_string(v2c) << std::endl;

	return 0;
}

# data[].attributes.body
#define GLM_FORCE_SWIZZLE

#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

void func1()

{

// Move point p by vector v

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

glm::vec3 result = p + v;

std::cout << glm::to_string(result) << std::endl;

}

void func2()

{

// Add vectors v1 and v2

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

glm::vec3 result = v1 + v2;

std::cout << glm::to_string(result) << std::endl;

}

void func3()

{

// Multiply v1 with scalar 5

glm::vec3 v1(0, 1, 0);

v1 = v1 * 5.0f;

std::cout << glm::to_string(v1) << std::endl;

}

void func4()

{

// Get a vector v starting a (8, 2, 5) and ending at (1, -1, 4)

glm::vec3 p1(8, 2, 5);

glm::vec3 p2(1, -1, 4);

glm::vec3 v = p2 - p1;

std::cout << glm::to_string(v) << std::endl;

}

int main()

{

func1();

func2();

func3();

func4();

// Normalize vector v

glm::vec3 v(1, 3, 4);

v = glm::normalize(v);

std::cout << glm::to_string(v) << std::endl;

return 0;

}

# data[].attributes.body
```#include "Source.h"

using namespace std;

int main()

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

glm::vec3 first_example = p + v;

glm::vec3 second_example = v1 + v2;

glm::vec3 third_example = glm::vec3(0, 1, 0) * 5.0f;

glm::vec3 fourth_example = glm::vec3(1, -1, 4) - glm::vec3(8, 2, 5);

glm::vec3 fifth_example = glm::normalize(glm::vec3(1, 3, 4));

std::cout << "first_example: " << first_example.x << " " << first_example.y << " " << first_example.z << std::endl;

std::cout << "second_example: " << second_example.x << " " << second_example.y << " " << second_example.z << std::endl;

std::cout << "third_example: " << third_example.x << " " << third_example.y << " " << third_example.z << std::endl;

std::cout << "fourth_example: " << fourth_example.x << " " << fourth_example.y << " " << fourth_example.z << std::endl;

std::cout << "fifth_example: " << fifth_example.x << " " << fifth_example.y << " " << fifth_example.z << std::endl;

return 0;

}```

# data[].attributes.body
#include "CMakeProject2.h"

#include <glm/vec3.hpp>

glm::vec3 MovePoint(glm::vec3 p = glm::vec3(1, 4, -5), glm::vec3 v = glm::vec3(5, 1, 4))

{

	return p + v;

}

glm::vec3 AddVector(glm::vec3 v1 = glm::vec3(1, 0, 0), glm::vec3 v2 = glm::vec3(0, 1, 0))

{

	return v1 + v2;

}

glm::vec3 ScalarVector(float scalar = 5, glm::vec3 v1 = glm::vec3(0, 1, 0))

{

	return scalar * v1;

}

glm::vec3 GetVector(glm::vec3 p1 = glm::vec3(8, 2, 5), glm::vec3 p2 = glm::vec3(1, -1, 4))

{

	return p2 - p1;

}

glm::vec3 NormalizeVector(glm::vec3 v1 = glm::vec3(1, 3, 4))

{

	return glm::normalize(v1);

}

int main()

{

	std::cout << glm::to_string(MovePoint()) << std::endl;

	std::cout << glm::to_string(AddVector()) << std::endl;

	std::cout << glm::to_string(ScalarVector()) << std::endl;

	std::cout << glm::to_string(GetVector()) << std::endl;

	std::cout << glm::to_string(NormalizeVector()) << std::endl;

	return 0;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#define GLM_FORCE_SWIZZLE

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

#include <iostream>

template<typename T>

void display(T x)

{

static int logCount = 0;

++logCount;

std::cout << logCount << ": " << glm::to_string(x) << std::endl;

}

void exercice1()

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

p += v;

display(p);

}

void exercice2()

{

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

display(v1 + v2);

}

void exercice3()

{

glm::vec3 v1(0, 1, 0);

display(v1 * 5.f);

}

void exercice4()

{

glm::vec3 begin(8, 2, 5);

glm::vec3 end(1, -1, 4);

glm::vec3 v = end - begin;

display(v);

}

void exercice5()

{

glm::vec3 v(1, 3, 4);

display(glm::normalize(v));

}

int main()

{

// Exercice 1 - Move Point p(1,4,-5) by vector v(5,1,4)

exercice1();

// Exercice 2 - Add vector v1(1,0,0) and vector v2(0,1,0)

exercice2();

// Exercice 3 - Multiply v1(0,1,0) with scalar 5

exercice3();

// Exercice 4 - Get a vector v starting at (8,2,5) and ending at (1,-1,4)

exercice4();

// Exercice 5 - Normalize vector v(1,3,4)

exercice5();

return 0;

}

# data[].attributes.body
glm::vec3 ex1()

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

return p + v;

}

glm::vec3 ex2()

{

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

return v1 + v2;

}

glm::vec3 ex3()

{

glm::vec3 v1(0, 1, 0);

return v1 * 5.0f;

}

glm::vec3 ex4()

{

glm::vec3 v(8, 2, 5);

glm::vec3 endVec(1, -1, 4);

return endVec - v;

}

glm::vec3 ex5()

{

glm::vec3 v(1, 3, 4);

return glm::normalize(v);

}

int main()

{

glm::vec3 a(1, 3, 4);

glm::vec2 b(3, 4);

a = a * 3.0f;

a = 3.0f * a;

float l = glm::length(a);

std::cout << "Lenght of a : " << l << std::endl;

a = glm::normalize(a);

std::cout << glm::to_string(a) << std::endl;

a.xy = b.xx;

std::cout << glm::to_string(a) << std::endl;

return 0;

}

# data[].attributes.body
#include <glm/glm.hpp>
#include <iostream>

int main() {
  // Ex1 moving point
  glm::vec3 p(1, 4, -5);
  glm::vec3 v(4, 1, 4);
  auto moved = p + v;

  // Ex2 adding vectors
  glm::vec3 result = glm::vec3(1, 0, 0) + glm::vec3(0, 1, 0);

  // Ex4 mul by scalar
  glm::vec3 result = glm::vec3(0, 1, 0) * 5.0f;

  // Ex5 vec starting and ending
  glm::vec3 v = glm::vec3(1, -1, 4) - glm::vec3(8, 2, 5);

  // Ex6 normalize
  glm::vec3 result = glm::normalize(glm::vec3(1, 3, 4));

  return 0;
}

# data[].attributes.body
#define GLM_FORCE_SWIZZLE

#define GLM_ENABLE_EXPERIMENTAL

#include <glm/gtx/string_cast.hpp>

#include <glm/glm.hpp>

#include <iostream>

glm::vec3 MovePoint(glm::vec3 point, glm::vec3 vector)

{

return point + vector;

}

glm::vec3 AddVector(glm::vec3 vector1, glm::vec3 vector2)

{

return vector1 + vector2;

}

glm::vec3 ScaleVector(glm::vec3 vector, float scalar)

{

return vector * scalar;

}

glm::vec3 VectorFromTo(glm::vec3 from, glm::vec3 to)

{

return to - from;

}

glm::vec3 NormalizeVector(glm::vec3 vector)

{

return glm::normalize(vector);

}

int main()

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

glm::vec3 result = MovePoint(p, v);

std::cout << glm::to_string(result) << std::endl;

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

glm::vec3 result2 = AddVector(v1, v2);

std::cout << glm::to_string(result2) << std::endl;

v1 = glm::vec3(0, 1, 0);

float scalar = 5;

glm::vec3 result3 = ScaleVector(v1, scalar);

std::cout << glm::to_string(result3) << std::endl;

v = VectorFromTo(glm::vec3(8, 2, 5), glm::vec3(1, -1, 4));

std::cout << glm::to_string(v) << std::endl;

v = glm::vec3(1, 3, 4);

glm::vec3 result4 = NormalizeVector(v);

std::cout << glm::to_string(result4) << std::endl;

return 0;

}

# data[].attributes.body
#define GLM_FORCE_SWIZZLE

#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

//Exercice 1

glm::vec3 FirstEx() {

glm::vec3 p(1, 4, 5);

glm::vec3 v(5, 1, 4);

p = p + v;

return p;

}

//Exercice 2

glm::vec3 SecondEx() {

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

return v1 + v2;

}

//Exercice 3

glm::vec3 ThirdEx() {

glm::vec3 v1(1, 0, 0);

v1 = v1 * 5.0f;

return v1;

}

//Exercice 4

glm::vec3 FourthEx() {

glm::vec3 v(-7, -3, -1);

return v;

}

//Exercice 5

glm::vec3 FifthEx() {

glm::vec3 v(1, 3, 4);

v = glm::normalize(v);

return v;

}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#define GLM_FORCE_SWIZZLE

#include <glm/glm.hpp>

#include <glm/gtx/string_cast.hpp>

#include <iostream>

template<typename T>

void display(T x)

{

static int logCount = 0;

++logCount;

std::cout << logCount << ": " << glm::to_string(x) << std::endl;

}

void exercice1()

{

glm::vec3 p(1, 4, -5);

glm::vec3 v(5, 1, 4);

p += v;

display(p);

}

void exercice2()

{

glm::vec3 v1(1, 0, 0);

glm::vec3 v2(0, 1, 0);

display(v1 + v2);

}

void exercice3()

{

glm::vec3 v1(0, 1, 0);

display(v1 * 5.f);

}

void exercice4()

{

glm::vec3 begin(8, 2, 5);

glm::vec3 end(1, -1, 4);

glm::vec3 v = end - begin;

display(v);

}

void exercice5()

{

glm::vec3 v(1, 3, 4);

display(glm::normalize(v));

}

int main()

{

// Exercice 1 - Move Point p(1,4,-5) by vector v(5,1,4)

exercice1();

// Exercice 2 - Add vector v1(1,0,0) and vector v2(0,1,0)

exercice2();

// Exercice 3 - Multiply v1(0,1,0) with scalar 5

exercice3();

// Exercice 4 - Get a vector v starting at (8,2,5) and ending at (1,-1,4)

exercice4();

// Exercice 5 - Normalize vector v(1,3,4)

exercice5();

return 0;

}

# data[].attributes.body
#include <iostream>

#define GLM_ENABLE_EXPERIMENTAL

#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>


static glm::vec3 MovePoint(glm::vec3 point, glm::vec3 vector) {
	return point + vector;
}

static glm::vec3 AddVector(glm::vec3 vectorA, glm::vec3 vectorB) {
	return vectorA + vectorB;
}

static glm::vec3 MultiplyBy5(glm::vec3 vector) {
	return vector * 5.0f;
}

static glm::vec3 GetVectorV() {
	return glm::vec3(8, 2, 5) - glm::vec3(1, -1, 4);
}

static glm::vec3 NormalizeAVectorV() {
	return glm::normalize(glm::vec3(1, 3, 4));
}

int main() {
	glm::vec3 a(1, 4, -5);
	glm::vec3 b(5, 1, 4);

	glm::vec3 c = MovePoint(a, b);
	std::cout << "Move Point Result:" << glm::to_string(c) << std::endl;
	glm::vec3 d(1, 0, 0);
	glm::vec3 e(0, 1, 0);

	glm::vec3 f = AddVector(d, e);
	std::cout << "Add Vector Result:" << glm::to_string(f) << std::endl;

	glm::vec3 g = MultiplyBy5(e);
	std::cout << "Mutliply v1 Result:" << glm::to_string(g) << std::endl;
	std::cout << "Get Vector V Result:" << glm::to_string(GetVectorV()) << std::endl;
	std::cout << "Normalize V Result:" << glm::to_string(NormalizeAVectorV()) << std::endl;
	return 0;
}

# data[].attributes.body
#include <iostream>

#define GLM_ENABLE_EXPERIMENTAL

#include <glm/gtx/string_cast.hpp>
#include <glm/vec3.hpp>

int main(void) {
    glm::vec3 p(1, 4, -5);
    glm::vec3 v(5, 1, 4);
    p += v;

    glm::vec3 v1(1, 0, 0);
    glm::vec3 v2(0, 1, 0);
    v2 = v1 + v2;

    v1 = glm::vec3(0, 1, 0);
    v1 *= 5;

    v = glm::vec3(1,-1,4) - glm::vec3(8,2,5);

    std::cout << glm::to_string(p) << std::endl;
    std::cout << glm::to_string(v2) << std::endl;
    std::cout << glm::to_string(v1) << std::endl;
    std::cout << glm::to_string(v) << std::endl;
    v = glm::normalize(glm::vec3(1, 3, 4));
    std::cout << glm::to_string(v) << std::endl;

    return 0;
}

# data[].attributes.body
// src/main.cpp
#define GLM_ENABLE_EXPERIMENTAL
#define GLM_FORCE_SWIZZLE

#include <fmt/core.h> // Include fmt library
#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>
#include <iostream>


glm::vec3 movePoint() {
    glm::vec3 p(1, 4, -5);
    glm::vec3 v(5, 1, 4);

    p += v;
    return p;
}

glm::vec3 addVector() {
    glm::vec3 v1(1,0,0);
    glm::vec3 v2(0,1,0);

    return v1 + v2;
}

glm::vec3 multiplyVector() {
    glm::vec3 v1(0, 1, 0);

    return v1 * 5.0f;
}

glm::vec3 lineVector() {
    glm::vec3 start(8, 2, 5);
    glm::vec3 end(1, -1, 4);

    return end - start;
}

glm::vec3 normalizeVector() {
    glm::vec3 v1(1, 3, 4);

    return glm::normalize(v1);
}

int main() {

    std::cout << glm::to_string(movePoint()) << std::endl;
    std::cout << glm::to_string(addVector()) << std::endl;
    std::cout << glm::to_string(multiplyVector()) << std::endl;
    std::cout << glm::to_string(lineVector()) << std::endl;
    std::cout << glm::to_string(normalizeVector()) << std::endl;

    return 0;
}

# data[].attributes.body
#include "GameGraphicsCourses.h"

void movePoint(glm::vec3 point, glm::vec3 movement)

{

point += movement;

std::cout << "new point : " << glm::to_string(point) << std::endl;

}

void addVector(glm::vec3 vector1, glm::vec3 vector2)

{

vector1 += vector2;

std::cout << "new vector : " << glm::to_string(vector1) << std::endl;

}

void multiply(glm::vec3 vector, float scalar)

{

vector *= scalar;

std::cout << "new vector : " << glm::to_string(vector) << std::endl;

}

void normalize(glm::vec3 vector)

{

vector = glm::normalize(vector);

std::cout << "normalized vector : " << glm::to_string(vector) << std::endl;

}

void getVectorFrom2Points(glm::vec3 point1, glm::vec3 point2)

{

glm::vec3 vector = point2 - point1;

std::cout << "Vector form point1 : " << glm::to_string(point1) << " to point2 : " << glm::to_string(point2) << " is : " << glm::to_string(vector) << std::endl;

}

int main()

{

std::cout << "Hello CMake." << std::endl;

glm::vec3 point1 = glm::vec3(1.f, 4.f, -5.f);

glm::vec3 vec1 = glm::vec3(5.f, 1.f, 4.f);

movePoint(point1, vec1);

glm::vec3 vec2 = glm::vec3(1.f, 0.f, 0.f);

glm::vec3 vec3 = glm::vec3(0.f, 1.f, 0.f);

addVector(vec2, vec3);

glm::vec3 vec4 = glm::vec3(0.f, 1.f, 0.f);

float scalar = 5.f;

multiply(vec4, scalar);

glm::vec3 point2 = glm::vec3(8.f, 2.f, 5.f);

glm::vec3 point3 = glm::vec3(1.f, -1.f, 4.f);

getVectorFrom2Points(point2, point3);

glm::vec3 vectorToNormalize = glm::vec3(1.f, 3.f, 4.f);

normalize(vectorToNormalize);

return 0;

}

# data[].attributes.body
// Practice of GLM
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/string_cast.hpp>
#include <glm/vec3.hpp>
#include <iostream>

int MovePoint(glm::vec3 p, glm::vec3 v) {
    glm::vec3 pv = p + v;
    std::cout << glm::to_string(pv) << std::endl;
    return 0;
}

int MultiplyVector(glm::vec3 v1, float scalar) {
    glm::vec3 v2 = v1 * scalar;
    std::cout << glm::to_string(v2) << std::endl;
    return 0;
}

int GetVector(glm::vec3 start, glm::vec3 end) {
    glm::vec3 v = end - start;
    std::cout << glm::to_string(v) << std::endl;
    return 0;
}

int main() {
    // 1. Move Point p(1,4,-5) by vector v(5,1,4).
    glm::vec3 p(1, 4, -5);
    glm::vec3 v(5, 1, 4);
    std::cout << "1. Move Point p(1,4,-5) by vector v(5,1,4)." << std::endl;
    MovePoint(p, v);

    // 2. Add vector v1(1,0,0) and vector v2(0,1,0).
    glm::vec3 v1(1, 0, 0);
    glm::vec3 v2(0, 1, 0);
    std::cout << "2. Add vector v1(1,0,0) and vector v2(0,1,0)." << std::endl;
    MovePoint(v1, v2);

    // 3. Multiply v1(0,1,0) with scalar 5.
    std::cout << "3. Multiply v1(0,1,0) with scalar 5." << std::endl;
    MultiplyVector(v2, 5);

    // 4. Get a vector v starting at (8,2,5) and ending at (1,-1,4).
    glm::vec3 start(8, 2, 5);
    glm::vec3 end(1, -1, 4);
    std::cout << "4. Get a vector v starting at (8,2,5) and ending at (1,-1,4)." << std::endl;
    GetVector(start, end);

    // 5. Normalize vector v(1,3,4).
    glm::vec3 v3(1, 3, 4);
    glm::vec3 v4 = glm::normalize(v3);
    std::cout << "5. Normalize vector v(1,3,4)." << std::endl;
    std::cout << glm::to_string(v4) << std::endl;

    return 0;
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL

#include <iostream>

#include <glm/vec3.hpp>
#include <glm/gtx/string_cast.hpp>

glm::vec3 ex1()
{
	glm::vec3 p(1, 4, -5);
	glm::vec3 v(5, 1, 4);

	p += v;
	return p;
}

glm::vec3 ex2()
{
	glm::vec3 v1(1, 0, 0);
	glm::vec3 v2(0, 1, 0);

	return v1 + v2;
}

glm::vec3 ex3()
{
	glm::vec3 v1(0, 1, 0);
	float s = 5;

	return v1 * s;
}

glm::vec3 ex4()
{
	glm::vec3 start(8, 2, 5);
	glm::vec3 end(1, -1, 4);

	return end - start;
}

glm::vec3 ex5()
{
	glm::vec3 v(1, 3, 4);

	return glm::normalize(v);
}

int main()
{
	std::cout << "Ex 1: " << glm::to_string(ex1()) << std::endl;
	std::cout << "Ex 2: " << glm::to_string(ex2()) << std::endl;
	std::cout << "Ex 3: " << glm::to_string(ex3()) << std::endl;
	std::cout << "Ex 4: " << glm::to_string(ex4()) << std::endl;
	std::cout << "Ex 5: " << glm::to_string(ex5()) << std::endl;
	return (0);
}

# data[].attributes.body
#define GLM_ENABLE_EXPERIMENTAL
    #include <glm/gtx/string_cast.hpp>
    #include <glm/glm.hpp>
#include <iostream>

void MovePoint(glm::vec3& point, const glm::vec3& translation)
{
    point += translation;
}

glm::vec3 AddVectors(const glm::vec3& v1, const glm::vec3& v2)
{
    glm::vec3 result = v1 + v2;

    return result;
}

glm::vec3 MultiplyVector(const glm::vec3& v, float scalar)
{
    glm::vec3 result = v * scalar;

    return result;
}

glm::vec3 GetVector(const glm::vec3& start, const glm::vec3& end)
{
    glm::vec3 result = end - start;

    return result;
}

void NormalizeVector(glm::vec3& v)
{
    v = glm::normalize(v);
}

int main()
{
    // -- Exercice 1 -- //
    glm::vec3 point(1.f, 4.f, -5.f);
    glm::vec3 translation(5.f, 1.f, 4.f);

    std::cout << "Exercice 1: "; MovePoint(point, translation); std::cout << glm::to_string(point) << std::endl;

    // -- Exercice 2 -- //
    glm::vec3 v1(1.f, 0.f, 0.f);
    glm::vec3 v2(0.f, 1.f, 0.f);

    std::cout << "Exercice 2: ";  std::cout << glm::to_string(AddVectors(v1, v2)) << std::endl;

    // -- Exercice 3 -- //
    std::cout << "Exercice 3: "; std::cout << glm::to_string(MultiplyVector(v2, 5.f)) << std::endl;

    // -- Exercice 4 -- //
    glm::vec3 start(8.f, 2.f, 5.f);
    glm::vec3 end(1.f, -1.f, 4.f);

    std::cout << "Exercice 4: "; std::cout << glm::to_string(GetVector(start, end)) << std::endl;

    // -- Exercice 5 -- //
    glm::vec3 normalizeVector(1.f, 3.f, 4.f);

    std::cout << "Exercice 5: "; NormalizeVector(normalizeVector); std::cout << glm::to_string(normalizeVector) << std::endl;
    return 0;
}