急求!!C语言绘制椭圆并使其旋转

来源:百度知道 编辑:UC知道 时间:2024/06/24 11:11:56
题目:绘制椭圆并使其旋转
要求:在屏幕上画一个椭圆,要求每按一次键盘,该椭圆转动30度。椭圆显示的位置、大小和转动的方向由键盘输入,并将输入的数据送文件保存。按回车键程序结束。(功能延伸:改变数据文件的内容后,再根据数据文件里的数据绘制椭圆)
谢谢大家啦

/* 旋转的立体椭球 */
#include <graphics.h>
#include <math.h>
#include <conio.h>
#define PI 3.14159
#define T PI/180
#define NN 36
#define DT PI/NN
#define DIST 0.8
#define R 190
static int n=1;
void trans(t,s)
float t[3];
float s[3][3];
{
s[0][0]=cos(t[1])*cos(t[2]); s[0][1]=cos(t[1])*sin(t[2]);
s[0][2]=-sin(t[1]);
s[1][0]=sin(t[0])*sin(t[1])*cos(t[2])-cos(t[0])*sin(t[2]);
s[1][1]=sin(t[0])*sin(t[1])*sin(t[2])+cos(t[0])*cos(t[2]);
s[1][2]=sin(t[0])*cos(t[1]);
s[2][0]=cos(t[0])*sin(t[1])*cos(t[2])+sin(t[0])*sin(t[2]);
s[2][1]=cos(t[0])*sin(t[0])*sin(t[2])-sin(t[0])*cos(t[2]);
s[2][2]=cos(t[0])*cos(t[1]);
}
void draw(m,da,db)
float m[3][3],da,db;
{
float f[3],f0 , x0,y0,x1,y1,x2,y2;
f[0]=R*sin(da)*cos(db); f[1]=R*sin(da)*sin(db);
f[2]=R*cos(da);
f0=f[0]*m[0][2]+f[1]*m[1][2]+f[2]*m[2][2];
if(f0<