[그래픽스] 그래픽 프로그래밍 설계 기말고사
1. Barycentric coordinates 설명하시오. 1) 정의 : 삼각형과 상대적으로 계산된 좌표를 말한다. 예를들어, 삼각형 ABC가 있다면, 세 정점 A, B, C를 각각 (1, 0, 0), (0, 1, 0), (0, 0, 1)의 좌표를 갖도록 축을 설정하여 상대적으로 좌표 공간을 생성하고, 삼각형 안 또는 밖에 있는 정점들의 위치값을 계산할 수 있는 좌표이다. 2) 특징 : 정점이 삼각형 내부에 있을 때만 모두 양수로 계산된다. 삼각형의 각도에 의존하 지 않는 성질이 있다. 3) 활용 : 삼각형에 대한 위치 결정에 사용된다. 내부의 점 또는 외부의 점을 설명하는 데에 해당 좌표를 활용할 수 있다. 또한, 삼각형을 interpolation 할 때 사용된다. 2. 변환은 모델링과 애니메이션에 ..
2022. 2. 9.
[그래픽스] 2D 애니메이션 (니모를 찾는 니모 아빠와 도리)
#include "cg.h" #include "draw.h" int w = 1000; int h = 1000; float t = 0.0; void display() { glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.2, 0.2, 1.0, 1.0); // center glColor3f(0.2, 0.2, 1.0); rect(vector2D(-0.1, 0.1), vector2D(0.1, -0.1)); // Nemo's body glPushMatrix(); glRotatef(20.0 * t, 0.0, 0.0, 1.0); glTranslatef(0.0, 0.5 + 0.05 * sin(4 * t), 0.0); glColor3f(1.0, 0.6, 0.0); ellipse(vector..
2022. 2. 9.
[알고리즘] Assignment 5 - LCS 알고리즘, BFS 알고리즘, Kruskal 알고리즘, Dijkstra 알고리즘, Prim 알고리즘
1. LCS (Longest Common Subsequence, 최장 공통 부분 문자열) #include #define MAX(a,b) ((a)>(b)? (a):(b)) int LCS_table[10][10] = { 0, }; void LCS_length(int str1_len, int str2_len, char* str1, char* str2) { for (int i = 1; i < str1_len; i++) { for (int j = 1; j < str2_len; j++) { if (str1[i] == str2[j]) { LCS_table[i][j] = LCS_table[i - 1][j - 1] + 1; } else { LCS_table[i][j] = MAX(LCS_table[i - 1][j], LC..
2022. 1. 28.
[알고리즘] Assignment 3 - 정렬 알고리즘 (bubble sort, insertion sort, merge sort, quick sort, radix sort, bucket sort)
1. Code #include #include #define SIZE 1000 #define DIGIT 4 int origin[SIZE], result[SIZE], result_2[SIZE]; void bubble_sort() { int i, j, temp; for (i = SIZE - 1; i > 0; i--) { for (j = 0; j origin[j + 1]) { temp = origin[j]; origin[j] = origin[j + 1]; origin[j + 1] = temp; } } } } void insertion_sort() { int i, j, temp; for (i = 1; i < SIZE; i++) { temp = origin[i];..
2022. 1. 28.