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

#define GLM_SWIZZLE

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

int main() {
//1 move Point p(1,4,-5) to vector v(5,1,4)
glm::vec3 p(1, 4, -5);
glm::vec3 v(5, 1, 4);
glm::vec3 d = p - v;
glm::vec3 MovePoint = p + d;
std::cout << glm::to_string(p) << std::endl;
std::cout << glm::to_string(v) << std::endl;
std::cout << glm::to_string(d) << std::endl;
std::cout << glm::to_string(MovePoint) << std::endl;
std::cout << "----------------------" << std::endl;

//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);
glm::vec3 addVector = v1 + v2;
std::cout << glm::to_string(v1) << std::endl;
std::cout << glm::to_string(v2) << std::endl;
std::cout << glm::to_string(addVector) << std::endl;
std::cout << "----------------------" << std::endl;

//3 multiply v1(0,1,0) with scalar 5
glm::vec3 v3(0, 1, 0);
glm::vec3 multiply = v3 * 5.0f;
std::cout << glm::to_string(v3) << std::endl;
std::cout << glm::to_string(multiply) << std::endl;
std::cout << "----------------------" << std::endl;

//4 get a vector v starting at (8,2,5) and ending at (1,-1, 4)
glm::vec3 starting(8, 2, 5);
glm::vec3 ending(1, -1, 4);
glm::vec3 StartEnd = ending - starting;
std::cout << glm::to_string(starting) << std::endl;
std::cout << glm::to_string(ending) << std::endl;
std::cout << glm::to_string(StartEnd) << std::endl;
std::cout << "----------------------" << std::endl;

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

return 0;
}

# data[].attributes.body
1. vec3 a(1, 4, -5);
vec3 b(5, 1, 4);
a = a + b;

2. vec3 v1(1, 0, 0);
vec3 v2(0, 1, 0);
vec3 v3 = v1 + v2;

3. vec3 v1(0, 1, 0);
v1 = v1 * 5.0f

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

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

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

using namespace std;

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

glm::vec3 tmp = v - p;
glm::vec3 p2v = p + tmp;

cout << "1번 : " << glm::to_string(p2v) << endl;

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

glm::vec3 v3 = v1 + v2;

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

//3
glm::vec3 v_3(0, 5, 0);
v_3 *= 5.0f;

cout << "3번 : " << glm::to_string(v_3) << endl;

//4
glm::vec3 p_start(8, 2, 5);
glm::vec3 p_end(1, -1, 4);

glm::vec3 vec = p_end - p_start;

cout << "4번 : " << glm::to_string(vec) << endl;

//5 : Normalize vector v(1,3,4).
glm::vec3 normalized(1, 3, 4);
normalized = glm::normalize(normalized);

cout << "5번 : " << glm::to_string(normalized) << endl;

}

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

int main()
{
//1 : Moving Point p(1,4,-5) to vector  v(5,1,4).
glm::vec3 p(1,4, -5);
glm::vec3 v(5,1,4);

glm::vec3 vecpv = v - p;
glm::vec3 ptov = p + vecpv;

//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);

glm::vec3 v3 = v1 + v2;

//3 : Multiply v1(0,1,0) with  scalar 5.
glm::vec3 v4(0, 5, 0);
v4 *= 5.0f;

//4 :Get a vector v starting at (8,2,5) and ending at (1,-1,4)
glm::vec3 s1(8, 2, 5);
glm::vec3 s(1, -1, 4);

glm::vec3 vecv = s - s1;

//5 : Normalize vector v(1,3,4).
glm::vec3 normv(1,3,4);
normv = glm::normalize(v);

std::cout << "1번 답 : " << glm::to_string(ptov) << std::endl;
std::cout << "2번 답 : " << glm::to_string(v3) << std::endl;
std::cout << "3번 답 : " << glm::to_string(v4) << std::endl;
std::cout << "4번 답 : " << glm::to_string(vecv) << std::endl;
std::cout << "5번 답 : " << glm::to_string(normv) << std::endl;

return 0;
}

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

using namespace std;
using namespace glm;

#define GLM_FORCE_SWIZZLE

void main()
{
//Practice 1. Move Point p(1,4,-5) to vector v(5,1,4)
vec3 p(1, 4, -5);
vec3 v(5, 1, 4);
vec3 temp = v - p;
vec3 moved_p = p + temp;

cout << "Practice 1." << endl;
cout << "p : " << to_string(p) << endl;
cout << "v : " << to_string(v) << endl;
cout << "temp : " << to_string(temp) << endl;
cout << "moved_p : " << to_string(moved_p) << endl << endl;;

//Practice 2. Add vector v1(1,0,0) and vector v2(0,1,0)
vec3 v1(1, 0, 0);
vec3 v2(0, 1, 0);
vec3 add_v1_v2 = v1 + v2;

cout << "Practice 2." << endl;
cout << "v1 : " << to_string(v1) << endl;
cout << "v2 : " << to_string(v2) << endl;
cout << "add_v1_v2 : " << to_string(add_v1_v2) << endl << endl;

//Practice 3. Multiply v1(0,1,0) with scalar 5.
vec3 v3(0, 1, 0);
vec3 multiply_v3 = v3 * 5.0f;

cout << "Practice 3." << endl;
cout << "v3 : " << to_string(v3) << endl;
cout << "multiply_v3 : " << to_string(multiply_v3) << endl << endl;

//Practice 4. Get a vector v starting at (8,2,5) and ending at(1,-1,4)
vec3 starting_v(8, 2, 5);
vec3 ending_v(1, -1, 4);
vec3 new_v = ending_v - starting_v;

cout << "Practice 4." << endl;
cout << "starting_v : " << to_string(starting_v) << endl;
cout << "ending_v : " << to_string(ending_v) << endl;
cout << "new_v : " << to_string(new_v) << endl << endl;

//Practice 5. Normalize vector v(1,3,4)
vec3 v5(1, 3, 4);
vec3 normalized_v5 = normalize(v5);

cout << "Practice 5." << endl;
cout << "v5 : " << to_string(v5) << endl;
cout << "normalized_v5 : " << to_string(normalized_v5) << endl;
}

# data[].attributes.body
#define GLM_SWIZZLE

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

int main()
{
//1번문제
glm::vec3 p(1, 4, -5);
glm::vec3 v(5, 1, 4);
glm::vec3 p_v_gap = v - p;
glm::vec3 move_ptov = p + p_v_gap;
std::cout << "Q1" << std::endl << glm::to_string(move_ptov) << std::endl;

//2번문제
glm::vec3 v1(1, 0, 0);
glm::vec3 v2(0, 1, 0);
glm::vec3 add_v1v2 = v1 + v2;
std::cout << "Q2" << std::endl << glm::to_string(add_v1v2) << std::endl;

//3번문제
glm::vec3 v3(0, 1, 0);
glm::vec3 mul_v3 = v3 * 5.0f;
std::cout << "Q3" << std::endl << glm::to_string(mul_v3) << std::endl;

//4번문제
glm::vec3 starting(8, 2, 5);
glm::vec3 ending(1, -1, 4);
glm::vec3 gap = ending - starting;
std::cout << "Q4" << std::endl << glm::to_string(gap) << std::endl;

//5번문제
glm::vec3 v4(1, 3, 4);
glm::vec3 normal_v4 = glm::normalize(v4);
std::cout << "Q5" << std::endl << glm::to_string(normal_v4) << std::endl;

return 0;
}

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

int main()
{
//1) Moving P to V
glm::vec3 P(1, 4, -5);
glm::vec3 V(5, 1, 4);
glm::vec3 MovedPoint = P + V;

//2) Adding V1 and V2
glm::vec3 V1(1, 0, 0);
glm::vec3 V2(0, 1, 0);
glm::vec3 addedVector = V1 + V2;

//3) Multiplying
glm::vec3 multipliedVector = V1 * 5.0f;

//4) Getting Vector V
glm::vec3 starting(8, 2, 5);
glm::vec3 ending(1, -1, 4);
glm::vec3 vector = ending - starting;

//5) Normalizing v
glm::vec3 v(8, 2, 5);
glm::vec3 normalizedV = glm::normalize(v);

return 0;
}

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

#define GLM_SWIZZLE

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

int main() {
//Q1
glm::vec3 p(1, 4, -5);
glm::vec3 v(5, 1, 4);
glm::vec3 move = p + v;
std::cout << glm::to_string(move) << std::endl;
//Q2
glm::vec3 v1(1, 0, 0);
glm::vec3 v2(0, 1, 0);
std::cout << glm::to_string(v1) << std::endl
<< glm::to_string(v2) << std::endl;
//Q3
glm::vec3 v3(0, 1, 0);
glm::vec3 mul = v3 * 5.0f;
std::cout << glm::to_string(mul) << std::endl;
//Q4
glm::vec3 start(8, 2, 5);
glm::vec3 ending(1, -1, 4);
glm::vec3 dist = ending - start;
std::cout << glm::to_string(dist) << std::endl;
//Q5
glm::vec3 v4(1, 3, 4);
glm::vec3 n = glm::normalize(v);
std::cout << glm::to_string(n) << std::endl;

return 0;
}

# data[].attributes.body
//1.move point p(1, 4, -5) to vector v(5, 1, 4)

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

//2.add vector v1(1, 0, 0) and vector2(0, 1, 0)

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

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

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

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

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

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

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

# data[].attributes.body
source code here
1.
2.
3.
4.
5