多边形顺时针方向判断公式及C++代码实现一

//#include "PolygonInterMul.h" #pragma once //编译一次 #ifndef Const_PI_H #define Const_PI_H const double PI=3.141592654; const double e=2.718; #endif #ifndef PolygonInterMul_H #define PolygonInterMul_H //顶点对象 public struct Top_Point { void set(double x,double y,double z) { this->X =x; this->Y =y; this->Z =z; }; double X; double Y; double Z; }; //顶点对象 public class Top_PointClass { public: void set(double x,double y,double z) { this->X =x; this->Y =y; this->Z =z; }; double X; double Y; double Z; }; //失量/向量 public struct Vertex { void set(double i,double j,double k) { this->I=i; this->J=j; this->K=k; }; double I; double J; double K; }; // class PolygonInterMul { public : PolygonInterMul(); ~PolygonInterMul(); public : //求向量p1->p2 Vertex getVertex(Top_Point p1,Top_Point p2); //求叉积 Vertex getInterMul(Vertex v1,Vertex v2); //求向量夹角 double getJJ(Vertex v1,Vertex v2); //测试 void Test(); //三顶点求面积p1->p2->p3 (顶点成逆时针回路) double getArea(Top_Point p1,Top_Point p2,Top_Point p3); //多顶点求面积 (顶点成逆时针回路) 梯形法 double getArea(System::Collections::ArrayList PointList); double getArea(Top_PointClass *PointArray); //?? private: double Nums; }; #endif

转载于:https://www.cnblogs.com/sqlite3/archive/2009/01/16/2566988.html

//样本程序: 旋转的六边形 #include "stdafx.h" #include #include #define PI 3.14159 //设置圆周率 int n=6, R=10; //多边形变数,外接圆半径 float theta=0.0; //旋转初始角度值 void Keyboard(unsigned char key, int x, int y); void Display(void); void Reshape(int w, int h); void myidle(); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); char *argv[] = {"hello ", " "}; int argc = 2; // must/should match the number of strings in argv glutInit(&argc;, argv); //初始化GLUT库; glutInitWindowSize(700,700); //设置显示窗口大小 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); //设置显示模式;(注意双缓冲) glutCreateWindow("A Rotating Square"); // 创建显示窗口 glutDisplayFunc(Display); //注册显示回调函数 glutReshapeFunc(Reshape); //注册窗口改变回调函数 glutIdleFunc(myidle); //注册闲置回调函数 glutMainLoop(); //进入事件处理循环 return 0; } void Display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0,0,0); //设置红色绘图颜色 glBegin(GL_POLYGON); //开始绘制六边形 for (int i=0;i=2*PI) theta-=2*PI; glutPostRedisplay(); //重画,相当于重新调用Display(),改编后的变量得以传给绘制函数 } void Reshape(GLsizei w,GLsizei h) { glMatrixMode(GL_PROJECTION); //投影矩阵模式 glLoadIdentity(); //矩阵堆栈清空 gluOrtho2D(-1.5*R*w/h,1.5*R*w/h,-1.5*R,1.5*R); //设置裁剪窗口大小 glViewport(0,0,w,h); //设置视区大小 glMatrixMode(GL_MODELVIEW); //模型矩阵模式 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值