// Keisanki Joron 2 (Introduction to Computing II) // Dept. of Engineering Systems, University of Tsukuba // 2006/09/05, kameda@iit.tsukuba.ac.jp Y.Kameda //----------------------------------------------------- // データ構造を扱う関数/メモリ管理 //----------------------------------------------------- struct POINT *new_POINT(void); struct LINE *new_LINE(void); struct FIGURE *new_FIGURE (void); struct PARAMETER *new_PARAMETER (void); void free_LINE (struct LINE *line); void free_FIGURE (struct FIGURE *figure); void free_all_FIGUREs (struct FIGURE *figure); void free_PARAMETER(struct PARAMETER *parameter); void free_all_PARAMETER(struct PARAMETER *parameter); void print_LINE (struct LINE *line); void print_all_LINEs (struct LINE *line); void print_FIGURE (struct FIGURE *figure); void print_all_FIGURE (struct FIGURE *figure); void print_PARAMETER (struct PARAMETER *parameter); void print_matrix (mat4x4 matrix); //----------------------------------------------------- // データファイルからの読み込み //----------------------------------------------------- void load_LINE (char *command); void attach_new_FIGURE (void); //----------------------------------------------------- // 描画関数 //----------------------------------------------------- void draw_LINE (struct LINE *line); void draw_FIGURE (struct FIGURE *figure); void draw_all_FIGURE (struct FIGURE *figure); void draw_FIGURE_continuously (struct FIGURE *figure); void read_commandfile (FILE *commandFile); //----------------------------------------------------- // 行列操作関数(主に幾何変換操作のときに必要) //----------------------------------------------------- void copy_matrix (mat4x4 copy, mat4x4 original); void compose_matrix (mat4x4 orimat, mat4x4 mulmat); //----------------------------------------------------- // 幾何変換操作のための関数 //----------------------------------------------------- void simple_translation (double dx, double dy, double dz, mat4x4 matrix); void simple_rotation_x (double thetax, mat4x4 matrix); void simple_rotation_y (double thetay, mat4x4 matrix); void simple_rotation_z (double thetaz, mat4x4 matrix); void simple_scaling (double sx, double sy, double sz, mat4x4 matrix); void create_transform_matrix (struct PARAMETER *parameter); struct POINT *POINT_transform (mat4x4 mat, struct POINT *point); struct LINE *LINE_transform (struct LINE *line, struct PARAMETER *parameter); struct POINT *perspective_projection (struct POINT *point); void normalized_draw_LINE (struct LINE *line); void draw_FIGURE_transform(struct FIGURE *figure, struct PARAMETER *parameter); //----------------------------------------------------- // アニメーションを行うための関数 //----------------------------------------------------- struct PARAMETER *PARAMETER_interpolation(struct PARAMETER *parameter1, struct PARAMETER *parameter2, double ratio); void animation_test (struct FIGURE *figure); //----------------------------------------------------- // ここからはウィンドウに種々のイベントが発生したときに // どう動くかを規定する関数群 //----------------------------------------------------- void kj_display (void); void kj_reshape (int w, int h); void kj_keyfunc (unsigned char key, int x, int y); void kj_mousefunc (int button, int status, int mouse_x, int mouse_y): //----------------------------------------------------- // ここからが本体 //----------------------------------------------------- int main (int argc, char *argv[]);