본문 바로가기

전체 글171

[그래픽스] 그래픽 프로그래밍 설계 기말고사 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.
[그래픽스] 나만의 드로잉 2022. 2. 9.
[그래픽스] 나만의 필터 만들기 레트로 감성, 노이즈 필터를 만들어보았습니다. 먼저, 필터의 컨셉입니다. 최근 레트로, 복고 등의 열풍이 불면서 인기를 얻은 추억의 물건 중 하나는 바로 필름카메라인데요. 필름카메라의 색감과 빛을 담는 방식이 인기를 얻자, 사람들은 스마트폰과 컴퓨터를 이용해 '마치 필카로 찍은듯한' 보정을 하기 시작했습니다. 각종 필터 어플에서도 레트로 테마가 유행입니다. 레트로 테마 필터의 특징 중 가장 두드러지고, 또 제가 개인적으로 좋아하는 부분은 바로 노이즈, 잡음입니다. 지금 보여드리는 두 사진은 팬들이 레트로 감성으로 보정한 연예인들의 사진입니다. 사진을 자세히 보시면 먼지와 같은 필터가 껴있음을 알 수 있습니다. 이 노이즈는 옛날 카메라의 화질저하 현상을 인위적으로 구현했다고 생각하시면 됩니다. 이번 수업을.. 2022. 2. 8.
[그래픽스] line.cpp 만들기 vec.h #pragma once #include #include #define M_PI 3.14159265358979323846 #define radians(x) x*M_PI/180.0 #define degrees(x) x*180.0/M_PI ////////////////////////////////////////////////////////////////////////////// // // 2D vector // ///////////////////////////////////////////////////////////////////////////// class vector2D { float x; float y; public: // // --- Constructors and Destructors ---.. 2022. 1. 28.
[알고리즘] 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 4 Implement the following algorithms in the C programming language and put the described input to the algorithm in order to check the answer. Submit 1) a report containing outputs of the following problems and 2) the codes you have written (screenshots okay). 1. Implement an algorithm of Fibonacci numbers using dynamic programming and get the answers when feeding 𝑛=5 and 𝑛=10 into the algorithm as.. 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.
[알고리즘] Assignment 2 Submit a word, hwp or pdf file to the e-class that contains (1) your answers for the following exercises, and (2) your codes written in the C programming language and their results for programming exercises (screenshots okay). 1. (programming) Write a program that takes a number n and displays the largest k satisfying the following equations: 2^k 2022. 1. 28.