gl

2、事例二 : 三角形的几何变换平移(Translate)、旋转(Scale)、缩放(Rotate)

倖福魔咒の 提交于 2019-11-27 10:06:31
namespace sharpGLTest02 { public partial class Form1 : Form { private int mtype = 3; public Form1() { InitializeComponent(); } //初始化 private void openGLControl1_OpenGLInitialized(object sender, EventArgs e) { } //调整 private void openGLControl1_Resize(object sender, EventArgs e) { } //画图 private void openGLControl1_OpenGLDraw(object sender, PaintEventArgs e) { SharpGL.OpenGL gl = this.openGLControl1.OpenGL; gl.ClearColor(0, 0, 0, 1); //清除深度缓存 gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); switch (mtype) { case 0: translateSample(gl); break; case 1: rotateSample(gl); break;

5、事例五:视口变换(Viewport)

两盒软妹~` 提交于 2019-11-27 10:06:10
namespace sharpGLTest05 { public partial class SharpGLForm : Form { public SharpGLForm() { InitializeComponent(); } private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { OpenGL gl = openGLControl.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); display(gl); } void display(OpenGL gl) { gl.Color(1.0, 0.0, 0.0); /* * Viewport()函数,可以将透视投影、正射投影等类似的视景体显示到屏幕指定的区域内 * 默认情况下,视口就是你用来绘制3D图像的整个矩形区域 * 1)Viewport定义了视口在窗口中的区域,同时也规定看二维像素平面到视口区域的映射关系 * 2)可以利用Viewport()生成多窗口效果 * Viewport(0,0,w/2,h/2); 左下角 * Viewport(w/2,0,w/2,h/2); 右下角 * Viewport(0

网络流-最小费用最大流

为君一笑 提交于 2019-11-26 18:17:21
定义 有时,网络中每条边除了容量还有费用。最小费用最大流(MincostMaxflow,简称MCMF)就是在最大流的基础上,费用最小。 实现 和EK类似,最小费用最大流的求法也是暴力寻找增广路,但是不是用Bfs进行增广,而是用Bellman-Ford或者Spfa进行增广。寻找增广路时,先要满足可以增广,然后检查费用是否更优秀,两者都满足,才修正。这样增广下来,不难发现肯定满足费用最小。 这个算法的效率是玄学……但是实际运用中应该可能大概够了吧。 模板 实在没找到模板题,用 POJ2135 当模板题好了。 因为每条道路只能通过一次,所以我们可以认为每条道路的容量为1,费用为这条道路的长度(由于这道题是双向边,所以必须正反都建边)。但是要走回来怎么办?因为不能重复走,所以走回来就等价于走两次(已双向建边),我们可以增加两个虚拟节点0和n+1:0向1构造一条容量为2,费用为0的边,n向n+1构造一条容量为2,费用为0的边。然后直接刷最小费用最大流即可。 #include<cstdio> #include<cstring> #include<algorithm> using namespace std ; const int maxn= 1000 ,maxm= 40000 ; int n,m,E,lnk[maxn+ 5 ],son[maxm+ 5 ],nxt[maxm+ 5 ]; int