当前位置: 首页 > 编程笔记 >

OpenGL实现Bezier曲线的方法示例

何琨
2023-03-14
本文向大家介绍OpenGL实现Bezier曲线的方法示例,包括了OpenGL实现Bezier曲线的方法示例的使用技巧和注意事项,需要的朋友参考一下

Bezier曲线的形状是通过一组多边折线(特征多边形)的各顶点唯一地定义出来的。在这组顶点中:

(1)只有第一个顶点和最后一个顶点在曲线上;

(2)其余的顶点则用于定义曲线的导数、阶次和形状;

(3)第一条边和最后一条边则表示了曲线在两端点处的切线方向。

// BezierCurve.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">#include <span class="hljs-tag"><<span class="hljs-name">gl</span>/<span class="hljs-attr">glut.h</span>></span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">#include <span class="hljs-tag"><<span class="hljs-name">gl</span>/<span class="hljs-attr">GL.h</span>></span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">#define DIMENSION 2//定义维度为2维</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">typedef GLfloat VECTOR [DIMENSION];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">VECTOR points[4]= {{-1.0,-1.0},{0.0,2.0},{1.0,2.0},{2.0,1.0}};//四个控制点</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">GLint count =10000;//绘制10000个点</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">int ww,hh;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">void display()</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">{</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> VECTOR c[4];//此矩阵是P和M的积,就是控制点阵和Bezier基矩阵的乘积</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> for (int i =0;i<span class="hljs-tag"><<span class="hljs-name">DIMENSION;i++)</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">c</span>[<span class="hljs-attr">3</span>][<span class="hljs-attr">i</span>] = <span class="hljs-string">(0-points[0][i])+3*points[1][i]-3*points[2][i]+points[3][i];</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">c</span>[<span class="hljs-attr">2</span>][<span class="hljs-attr">i</span>] =       <span class="hljs-string">3*points[0][i]-6*points[1][i]+3*points[2][i];</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">c</span>[<span class="hljs-attr">1</span>][<span class="hljs-attr">i</span>] =               <span class="hljs-string">(0-3*points[0][i])+3*points[1][i];</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">c</span>[<span class="hljs-attr">0</span>][<span class="hljs-attr">i</span>] =                       <span class="hljs-string">points[0][i];</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">GLfloat</span> <span class="hljs-attr">v</span>[<span class="hljs-attr">DIMENSION</span>];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">GLfloat</span> <span class="hljs-attr">newV</span>[<span class="hljs-attr">DIMENSION</span>];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">GLfloat</span> <span class="hljs-attr">deltat</span> = <span class="hljs-string">1.0/count;</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">GLfloat</span> <span class="hljs-attr">t</span> = <span class="hljs-string">0.0;</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glBegin</span>(<span class="hljs-attr">GL_LINE_STRIP</span>);//绘制控制曲线</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="32"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  <span class="hljs-attr">glVertex2fv</span>(<span class="hljs-attr">points</span>[<span class="hljs-attr">0</span>]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="33"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  <span class="hljs-attr">glVertex2fv</span>(<span class="hljs-attr">points</span>[<span class="hljs-attr">1</span>]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="34"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  <span class="hljs-attr">glVertex2fv</span>(<span class="hljs-attr">points</span>[<span class="hljs-attr">2</span>]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="35"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  <span class="hljs-attr">glVertex2fv</span>(<span class="hljs-attr">points</span>[<span class="hljs-attr">3</span>]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="36"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glEnd</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="37"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glFlush</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="38"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="39"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">v</span>[<span class="hljs-attr">0</span>] = <span class="hljs-string">points[0][0];v[1]</span> = <span class="hljs-string">points[0][1];</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="40"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">for</span> (<span class="hljs-attr">int</span> <span class="hljs-attr">i</span> = <span class="hljs-string">0;i</span><<span class="hljs-attr">count</span>;<span class="hljs-attr">i</span>++)//绘制最终结果</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="41"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="42"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">t</span> += <span class="hljs-string">deltat;</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="43"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">newV</span>[<span class="hljs-attr">0</span>] = <span class="hljs-string">c[0][0]</span> + <span class="hljs-attr">t</span>*(<span class="hljs-attr">c</span>[<span class="hljs-attr">1</span>][<span class="hljs-attr">0</span>] + <span class="hljs-attr">t</span>*(<span class="hljs-attr">c</span>[<span class="hljs-attr">2</span>][<span class="hljs-attr">0</span>] + <span class="hljs-attr">t</span>*<span class="hljs-attr">c</span>[<span class="hljs-attr">3</span>][<span class="hljs-attr">0</span>]));</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="44"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">newV</span>[<span class="hljs-attr">1</span>] = <span class="hljs-string">c[0][1]</span> + <span class="hljs-attr">t</span>*(<span class="hljs-attr">c</span>[<span class="hljs-attr">1</span>][<span class="hljs-attr">1</span>] + <span class="hljs-attr">t</span>*(<span class="hljs-attr">c</span>[<span class="hljs-attr">2</span>][<span class="hljs-attr">1</span>] + <span class="hljs-attr">t</span>*<span class="hljs-attr">c</span>[<span class="hljs-attr">3</span>][<span class="hljs-attr">1</span>]));</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="45"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glColor3f</span>(<span class="hljs-attr">0.0</span>,<span class="hljs-attr">0.0</span>,<span class="hljs-attr">1.0</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="46"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glBegin</span>(<span class="hljs-attr">GL_LINES</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="47"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glVertex2fv</span>(<span class="hljs-attr">v</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="48"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glVertex2fv</span>(<span class="hljs-attr">newV</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="49"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glEnd</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="50"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glFlush</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="51"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">v</span>[<span class="hljs-attr">0</span>] = <span class="hljs-string">newV[0];v[1]</span> = <span class="hljs-string">newV[1];</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="52"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="53"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="54"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="55"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="56"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">}</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="57"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-attr">void</span> <span class="hljs-attr">init</span>()</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="58"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">{</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="59"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="60"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glClearColor</span>(<span class="hljs-attr">0.0</span> , <span class="hljs-attr">0.0</span> ,<span class="hljs-attr">0.0</span> , <span class="hljs-attr">0.0</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="61"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glColor3f</span>(<span class="hljs-attr">1.0</span> ,<span class="hljs-attr">1.0</span> ,<span class="hljs-attr">1.0</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="62"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="63"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glMatrixMode</span>(<span class="hljs-attr">GL_PROJECTION</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="64"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glLoadIdentity</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="65"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">gluOrtho2D</span>(<span class="hljs-attr">-4.0</span> ,<span class="hljs-attr">4.0</span> ,<span class="hljs-attr">-4.0</span> ,<span class="hljs-attr">4.0</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="66"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="67"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">}</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="68"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="69"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-attr">void</span> <span class="hljs-attr">main</span>(<span class="hljs-attr">int</span> <span class="hljs-attr">argc</span>,<span class="hljs-attr">char</span> **<span class="hljs-attr">argv</span>)</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="70"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">{</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="71"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glutInit</span>(&<span class="hljs-attr">argc</span>,<span class="hljs-attr">argv</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="72"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glutInitDisplayMode</span>(<span class="hljs-attr">GLUT_SINGLE</span>|<span class="hljs-attr">GLUT_RGB</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="73"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glutInitWindowSize</span>(<span class="hljs-attr">500</span>,<span class="hljs-attr">500</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="74"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glutInitWindowPosition</span>(<span class="hljs-attr">500</span>,<span class="hljs-attr">200</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="75"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glutCreateWindow</span>("<span class="hljs-attr">reshape</span>");</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="76"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> //<span class="hljs-attr">glutReshapeFunc</span>(<span class="hljs-attr">myreshape</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="77"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glutDisplayFunc</span>(<span class="hljs-attr">display</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="78"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">init</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="79"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> //<span class="hljs-attr">glutIdleFunc</span>(<span class="hljs-attr">myidle</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="80"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> //<span class="hljs-attr">glutKeyboardFunc</span>(<span class="hljs-attr">mykeyboard</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="81"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> //<span class="hljs-attr">glutSpecialFunc</span>(<span class="hljs-attr">myspecialkey</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="82"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="83"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-attr">glutMainLoop</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="84"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">}</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="85"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对小牛知识库的支持。如果你想了解更多相关内容请查看下面相关链接

 类似资料:
  • 本文向大家介绍Python实现曲线点抽稀算法的示例,包括了Python实现曲线点抽稀算法的示例的使用技巧和注意事项,需要的朋友参考一下 本文介绍了Python实现曲线点抽稀算法的示例,分享给大家,具体如下: 目录 何为抽稀 道格拉斯-普克(Douglas-Peuker)算法 垂距限值法 最后 正文 何为抽稀 在处理矢量化数据时,记录中往往会有很多重复数据,对进一步数据处理带来诸多不便。多余的数据一

  • 大家好,我需要一些帮助。我用Python(Tkinter)写了一个代码,它是绘制一个3度贝塞尔曲线,并且它是工作的。。。。kinda.我的问题是:我如何直接从键盘输入x和y坐标为控制点,而不是先x后y(像我的代码)。第二个问题是关于参数(u或t值。通常它是标准化的(值0到1),但对于循环将不工作的十进制值为步骤(我知道这是显而易见的:))。如果我把u=1-&>1000,然后除以1000,它在数字上

  • 我的的代码是: 我已经定义了所有的设置,绘制等,但我想发射球从开始到贝塞尔曲线的中间,只要空间被压一次。 你有什么建议吗?

  • 我试图画一条具有一定厚度的三次bezier路径,但曲线看起来像是一系列断开的线段(在我的例子中是3段)。这是一张截图(蓝色圆圈是曲线的控制点)。 我注意到在cocos2d-x测试中的“绘制原语”中也出现了同样的效果。不管怎样,我很确定应该有一个变通办法,但我自己找不到。此外,线条受到锯齿效应的影响,我不知道如何应用一个alpha阴影来避免它。 这是我使用的代码:

  • 本文向大家介绍tensorboard实现同时显示训练曲线和测试曲线,包括了tensorboard实现同时显示训练曲线和测试曲线的使用技巧和注意事项,需要的朋友参考一下 在做网络训练实验时,有时需要同时将训练曲线和测试曲线一起显示,便于观察网络训练效果。经过很多次踩坑后,终于解决了。 具体的方法是:设置两个writer,一个用于写训练的数据,一个用于写测试数据,并且这两个writer分别存在trai

  • 为了做到这一点,我将需要找到控制点的“边缘”曲线决定形状,然后填充形状,这是发现在两个新的曲线之间。然而,我很不确定如何做到这一点。我想过的一件事是通过简单地在连接原控制点和原终点的直线上画垂直段来确定新曲线的起点和终点,但这仍然不能解决为新曲线寻找新控制点的问题。