templeos-info/public/Wb/Adam/Gr/GrMath.HC.HTML

837 lines
80 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Graphics/Math&quot;</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cFB>gr_x_offsets</span><span class=cF0>[8]={-1, 0, 1,-1,1,-1,0,1},
<a name="l4"></a> </span><span class=cFB>gr_y_offsets</span><span class=cF0>[8]={-1,-1,-1, 0,0, 1,1,1},
<a name="l5"></a> </span><span class=cFB>gr_x_offsets2</span><span class=cF0>[4]={ 0,-1, 1, 0},
<a name="l6"></a> </span><span class=cFB>gr_y_offsets2</span><span class=cF0>[4]={-1, 0, 0, 1};
<a name="l7"></a>
<a name="l8"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Line</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *aux_data,</span><span class=cF9>I64</span><span class=cF0> x1,</span><span class=cF9>I64</span><span class=cF0> y1,</span><span class=cF9>I64</span><span class=cF0> z1,</span><span class=cF9>I64</span><span class=cF0> x2,</span><span class=cF9>I64</span><span class=cF0> y2,</span><span class=cF9>I64</span><span class=cF0> z2,
<a name="l9"></a> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *aux,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> step=1,</span><span class=cF9>I64</span><span class=cF0> </span><span class=cF1>start</span><span class=cF0>=0)
<a name="l10"></a>{</span><span class=cF2>//Step through line segment calling callback.</span><span class=cF0>
<a name="l11"></a></span><span class=cF2>//Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l12"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,d,dx=x2-x1,dy=y2-y1,dz=z2-z1,_x,_y,_z,
<a name="l13"></a> adx=</span><span class=cF5>AbsI64</span><span class=cF0>(dx),ady=</span><span class=cF5>AbsI64</span><span class=cF0>(dy),adz=</span><span class=cF5>AbsI64</span><span class=cF0>(dz);
<a name="l14"></a> </span><span class=cF1>Bool</span><span class=cF0> first=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l15"></a> </span><span class=cF1>if</span><span class=cF0> (adx&gt;=ady) </span><span class=cF7>{</span><span class=cF0>
<a name="l16"></a> </span><span class=cF1>if</span><span class=cF0> (adx&gt;=adz) {
<a name="l17"></a> </span><span class=cF1>if</span><span class=cF0> (d=adx) </span><span class=cF7>{</span><span class=cF0>
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (dx&gt;=0)
<a name="l19"></a> dx=0x100000000;
<a name="l20"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l21"></a> dx=-0x100000000;
<a name="l22"></a> dy=dy&lt;&lt;32/d;
<a name="l23"></a> dz=dz&lt;&lt;32/d;
<a name="l24"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l25"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l26"></a> </span><span class=cF1>if</span><span class=cF0> (d=adz) </span><span class=cF7>{</span><span class=cF0>
<a name="l27"></a> dx=dx&lt;&lt;32/d;
<a name="l28"></a> dy=dy&lt;&lt;32/d;
<a name="l29"></a> </span><span class=cF1>if</span><span class=cF0> (dz&gt;=0)
<a name="l30"></a> dz=0x100000000;
<a name="l31"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l32"></a> dz=-0x100000000;
<a name="l33"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l34"></a> }
<a name="l35"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l36"></a> </span><span class=cF1>if</span><span class=cF0> (ady&gt;=adz) {
<a name="l37"></a> </span><span class=cF1>if</span><span class=cF0> (d=ady) </span><span class=cF7>{</span><span class=cF0>
<a name="l38"></a> dx=dx&lt;&lt;32/d;
<a name="l39"></a> </span><span class=cF1>if</span><span class=cF0> (dy&gt;=0)
<a name="l40"></a> dy=0x100000000;
<a name="l41"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l42"></a> dy=-0x100000000;
<a name="l43"></a> dz=dz&lt;&lt;32/d;
<a name="l44"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l45"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (d=adz) </span><span class=cF7>{</span><span class=cF0>
<a name="l47"></a> dx=dx&lt;&lt;32/d;
<a name="l48"></a> dy=dy&lt;&lt;32/d;
<a name="l49"></a> </span><span class=cF1>if</span><span class=cF0> (dz&gt;=0)
<a name="l50"></a> dz=0x100000000;
<a name="l51"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l52"></a> dz=-0x100000000;
<a name="l53"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l54"></a> }
<a name="l55"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l56"></a> x1&lt;&lt;=32; y1&lt;&lt;=32; z1&lt;&lt;=32;
<a name="l57"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;</span><span class=cF1>start</span><span class=cF0>;j++) </span><span class=cF7>{</span><span class=cF0>
<a name="l58"></a> x1+=dx; y1+=dy; z1+=dz;
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l60"></a> </span><span class=cF1>if</span><span class=cF0> (step!=1 &amp;&amp; step!=0) </span><span class=cF7>{</span><span class=cF0>
<a name="l61"></a> dx*=step;
<a name="l62"></a> dy*=step;
<a name="l63"></a> dz*=step;
<a name="l64"></a> d/=step;
<a name="l65"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l66"></a> </span><span class=cF1>for</span><span class=cF0> (i=</span><span class=cF1>start</span><span class=cF0>;i&lt;=d;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>_x!=x1.i32[1] || _y!=y1.i32[1] || _z!=z1.i32[1] || first</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l68"></a> !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,x1.i32[1],y1.i32[1],z1.i32[1]</span><span class=cF7>)</span><span class=cF0>)
<a name="l69"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l70"></a> first=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l71"></a> _x=x1.i32[1]; _y=y1.i32[1]; _z=z1.i32[1];
<a name="l72"></a> x1+=dx; y1+=dy; z1+=dz;
<a name="l73"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l74"></a> </span><span class=cF1>if</span><span class=cF0> (step==1 &amp;&amp; </span><span class=cF7>(</span><span class=cF0>_x!=x2||_y!=y2||_z!=z2</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,x2,y2,z2</span><span class=cF7>)</span><span class=cF0>)
<a name="l75"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l76"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l77"></a>}
<a name="l78"></a>
<a name="l79"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Graphics/Math/3D Transformation&quot;</span><span class=cF0>
<a name="l80"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4MulMat4x4Equ</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *dst,</span><span class=cF9>I64</span><span class=cF0> *m1,</span><span class=cF9>I64</span><span class=cF0> *m2)
<a name="l81"></a>{</span><span class=cF2>//Multiply 4x4 matrices and store in dst. Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l82"></a></span><span class=cF2>//Conceptually, the transform m1 is applied after m2</span><span class=cF0>
<a name="l83"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,k;
<a name="l84"></a> </span><span class=cF1>F64</span><span class=cF0> sum;
<a name="l85"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;4;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l86"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;4;j++) {
<a name="l87"></a> sum=0;
<a name="l88"></a> </span><span class=cF1>for</span><span class=cF0> (k=0;k&lt;4;k++)
<a name="l89"></a> sum+=</span><span class=cF5>ToF64</span><span class=cF0>(m1[k+4*j])*</span><span class=cF5>ToF64</span><span class=cF0>(m2[i+4*k]);
<a name="l90"></a> dst[i+4*j]=sum/</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l91"></a> }
<a name="l92"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l93"></a> </span><span class=cF1>return</span><span class=cF0> dst;
<a name="l94"></a>}
<a name="l95"></a>
<a name="l96"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4MulMat4x4New</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *m1,</span><span class=cF9>I64</span><span class=cF0> *m2,</span><span class=cF9>CTask</span><span class=cF0> *mem_task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l97"></a>{</span><span class=cF2>//Multiply 4x4 matrices. Return MAlloced matrix. Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l98"></a></span><span class=cF2>//Conceptually, the transform m1 is applied after m2</span><span class=cF0>
<a name="l99"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Mat4x4MulMat4x4Equ</span><span class=cF0>(</span><span class=cF5>MAlloc</span><span class=cF7>(</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0>)*16,mem_task</span><span class=cF7>)</span><span class=cF0>,m1,m2);
<a name="l100"></a>}
<a name="l101"></a>
<a name="l102"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4Equ</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *dst,</span><span class=cF9>I64</span><span class=cF0> *src)
<a name="l103"></a>{</span><span class=cF2>//Copy 4x4 Rot matrix.</span><span class=cF0>
<a name="l104"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(dst,src,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>*16);
<a name="l105"></a> </span><span class=cF1>return</span><span class=cF0> dst;
<a name="l106"></a>}
<a name="l107"></a>
<a name="l108"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4New</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *src,</span><span class=cF9>CTask</span><span class=cF0> *mem_task=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l109"></a>{</span><span class=cF2>//Return MAlloced copy of 4x4 Rot matrix.</span><span class=cF0>
<a name="l110"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Mat4x4Equ</span><span class=cF0>(</span><span class=cF5>MAlloc</span><span class=cF7>(</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0>)*16,mem_task</span><span class=cF7>)</span><span class=cF0>,src);
<a name="l111"></a>}
<a name="l112"></a>
<a name="l113"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4RotX</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *m,</span><span class=cF1>F64</span><span class=cF0> phi)
<a name="l114"></a>{</span><span class=cF2>//Rot matrix about X axis. Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l115"></a> </span><span class=cF1>F64</span><span class=cF0> my_cos=</span><span class=cF5>Cos</span><span class=cF0>(phi)*</span><span class=cF3>GR_SCALE</span><span class=cF0>,my_sin=</span><span class=cF5>Sin</span><span class=cF0>(phi)*</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l116"></a> </span><span class=cF9>I64</span><span class=cF0> r[16],r2[16];
<a name="l117"></a> </span><span class=cF5>MemSet</span><span class=cF0>(r,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>r</span><span class=cF7>)</span><span class=cF0>);
<a name="l118"></a> r[5]=my_cos;
<a name="l119"></a> r[10]=my_cos;
<a name="l120"></a> r[9]=my_sin;
<a name="l121"></a> r[6]=-my_sin;
<a name="l122"></a> r[0]=</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l123"></a> r[15]=</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l124"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Mat4x4Equ</span><span class=cF0>(m,</span><span class=cF5>Mat4x4MulMat4x4Equ</span><span class=cF7>(</span><span class=cF0>r2,r,m</span><span class=cF7>)</span><span class=cF0>);
<a name="l125"></a>}
<a name="l126"></a>
<a name="l127"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4RotY</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *m,</span><span class=cF1>F64</span><span class=cF0> omega)
<a name="l128"></a>{</span><span class=cF2>//Rot matrix about Y axis. Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l129"></a> </span><span class=cF1>F64</span><span class=cF0> my_cos=</span><span class=cF5>Cos</span><span class=cF0>(omega)*</span><span class=cF3>GR_SCALE</span><span class=cF0>,my_sin=</span><span class=cF5>Sin</span><span class=cF0>(omega)*</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l130"></a> </span><span class=cF9>I64</span><span class=cF0> r[16],r2[16];
<a name="l131"></a> </span><span class=cF5>MemSet</span><span class=cF0>(r,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>r</span><span class=cF7>)</span><span class=cF0>);
<a name="l132"></a> r[0]=my_cos;
<a name="l133"></a> r[10]=my_cos;
<a name="l134"></a> r[8]=-my_sin;
<a name="l135"></a> r[2]=my_sin;
<a name="l136"></a> r[5]=</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l137"></a> r[15]=</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l138"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Mat4x4Equ</span><span class=cF0>(m,</span><span class=cF5>Mat4x4MulMat4x4Equ</span><span class=cF7>(</span><span class=cF0>r2,r,m</span><span class=cF7>)</span><span class=cF0>);
<a name="l139"></a>}
<a name="l140"></a>
<a name="l141"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *m,</span><span class=cF1>F64</span><span class=cF0> theta)
<a name="l142"></a>{</span><span class=cF2>//Rot matrix about Z axis. Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l143"></a> </span><span class=cF1>F64</span><span class=cF0> my_cos=</span><span class=cF5>Cos</span><span class=cF0>(theta)*</span><span class=cF3>GR_SCALE</span><span class=cF0>,my_sin=</span><span class=cF5>Sin</span><span class=cF0>(theta)*</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l144"></a> </span><span class=cF9>I64</span><span class=cF0> r[16],r2[16];
<a name="l145"></a> </span><span class=cF5>MemSet</span><span class=cF0>(r,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>r</span><span class=cF7>)</span><span class=cF0>);
<a name="l146"></a> r[0]=my_cos;
<a name="l147"></a> r[5]=my_cos;
<a name="l148"></a> r[4]=my_sin;
<a name="l149"></a> r[1]=-my_sin;
<a name="l150"></a> r[10]=</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l151"></a> r[15]=</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l152"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Mat4x4Equ</span><span class=cF0>(m,</span><span class=cF5>Mat4x4MulMat4x4Equ</span><span class=cF7>(</span><span class=cF0>r2,r,m</span><span class=cF7>)</span><span class=cF0>);
<a name="l153"></a>}
<a name="l154"></a>
<a name="l155"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4Scale</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *m,</span><span class=cF1>F64</span><span class=cF0> s)
<a name="l156"></a>{</span><span class=cF2>//Scale 4x4 matrix by value.</span><span class=cF0>
<a name="l157"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l158"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;16;i++)
<a name="l159"></a> m[i]*=s;
<a name="l160"></a> </span><span class=cF1>return</span><span class=cF0> m;
<a name="l161"></a>}
<a name="l162"></a>
<a name="l163"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DCThickScale</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc)
<a name="l164"></a>{</span><span class=cF2>//Scale device context's thick by norm of transformation.</span><span class=cF0>
<a name="l165"></a> </span><span class=cF9>I64</span><span class=cF0> d;
<a name="l166"></a> </span><span class=cF1>if</span><span class=cF0> (dc-&gt;flags&amp;</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (dc-&gt;thick) {
<a name="l168"></a> d=dc-&gt;thick*dc-&gt;r_norm+0x80000000; </span><span class=cF2>//Round</span><span class=cF0>
<a name="l169"></a> dc-&gt;thick=d.i32[1];
<a name="l170"></a> </span><span class=cF1>if</span><span class=cF0> (dc-&gt;thick&lt;1)
<a name="l171"></a> dc-&gt;thick=1;
<a name="l172"></a> }
<a name="l173"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l174"></a>}
<a name="l175"></a>
<a name="l176"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4TranslationEqu</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *r,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z)
<a name="l177"></a>{</span><span class=cF2>//Set translation values in 4x4 matrix. Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l178"></a> r[0*4+3]=x&lt;&lt;32;
<a name="l179"></a> r[1*4+3]=y&lt;&lt;32;
<a name="l180"></a> r[2*4+3]=z&lt;&lt;32;
<a name="l181"></a> r[3*4+3]=</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l182"></a> </span><span class=cF1>return</span><span class=cF0> r;
<a name="l183"></a>}
<a name="l184"></a>
<a name="l185"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>Mat4x4TranslationAdd</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *r,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z)
<a name="l186"></a>{</span><span class=cF2>//Add translation to 4x4 matrix. Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l187"></a> r[0*4+3]+=x&lt;&lt;32;
<a name="l188"></a> r[1*4+3]+=y&lt;&lt;32;
<a name="l189"></a> r[2*4+3]+=z&lt;&lt;32;
<a name="l190"></a> r[3*4+3]=</span><span class=cF3>GR_SCALE</span><span class=cF0>;
<a name="l191"></a> </span><span class=cF1>return</span><span class=cF0> r;
<a name="l192"></a>}
<a name="l193"></a>
<a name="l194"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DCSymmetrySet</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc,</span><span class=cF9>I64</span><span class=cF0> x1,</span><span class=cF9>I64</span><span class=cF0> y1,</span><span class=cF9>I64</span><span class=cF0> x2,</span><span class=cF9>I64</span><span class=cF0> y2)
<a name="l195"></a>{</span><span class=cF2>//2D. Set device context's symmetry.</span><span class=cF0>
<a name="l196"></a> </span><span class=cF1>F64</span><span class=cF0> d;
<a name="l197"></a> </span><span class=cF1>if</span><span class=cF0> (y1==y2 &amp;&amp; x1==x2)
<a name="l198"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l199"></a> dc-&gt;sym.snx=y2-y1;
<a name="l200"></a> dc-&gt;sym.sny=x1-x2;
<a name="l201"></a> dc-&gt;sym.snz=0;
<a name="l202"></a> </span><span class=cF1>if</span><span class=cF0> (d=</span><span class=cF5>Sqrt</span><span class=cF7>(</span><span class=cF5>SqrI64</span><span class=cF0>(dc-&gt;sym.snx)+
<a name="l203"></a> </span><span class=cF5>SqrI64</span><span class=cF0>(dc-&gt;sym.sny)+
<a name="l204"></a> </span><span class=cF5>SqrI64</span><span class=cF0>(dc-&gt;sym.snz)</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l205"></a> d=</span><span class=cF3>GR_SCALE</span><span class=cF0>/d;
<a name="l206"></a> dc-&gt;sym.snx *= d;
<a name="l207"></a> dc-&gt;sym.sny *= d;
<a name="l208"></a> dc-&gt;sym.snz *= d;
<a name="l209"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l210"></a> dc-&gt;sym.sx=x1;
<a name="l211"></a> dc-&gt;sym.sy=y1;
<a name="l212"></a> dc-&gt;sym.sz=0;
<a name="l213"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l214"></a>}
<a name="l215"></a>
<a name="l216"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DCSymmetry3Set</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cFB>gr</span><span class=cF0>.dc,</span><span class=cF9>I64</span><span class=cF0> x1,</span><span class=cF9>I64</span><span class=cF0> y1,</span><span class=cF9>I64</span><span class=cF0> z1,
<a name="l217"></a> </span><span class=cF9>I64</span><span class=cF0> x2,</span><span class=cF9>I64</span><span class=cF0> y2,</span><span class=cF9>I64</span><span class=cF0> z2,</span><span class=cF9>I64</span><span class=cF0> x3,</span><span class=cF9>I64</span><span class=cF0> y3,</span><span class=cF9>I64</span><span class=cF0> z3)
<a name="l218"></a>{</span><span class=cF2>//3D. Set device context's symmetry.</span><span class=cF0>
<a name="l219"></a> </span><span class=cF1>F64</span><span class=cF0> d,x,y,z,xx,yy,zz;
<a name="l220"></a> </span><span class=cF9>I64</span><span class=cF0> xx1,yy1,zz1,xx2,yy2,zz2,*r;
<a name="l221"></a> xx1=x1-x2; yy1=y1-y2; zz1=z1-z2;
<a name="l222"></a> xx2=x3-x2; yy2=y3-y2; zz2=z3-z2;
<a name="l223"></a> </span><span class=cF1>if</span><span class=cF0> (!xx1 &amp;&amp; !yy1 &amp;&amp; !zz1 ||
<a name="l224"></a> !xx2 &amp;&amp; !yy2 &amp;&amp; !zz2 ||
<a name="l225"></a> xx1==xx2 &amp;&amp; yy1==yy2 &amp;&amp; zz1==zz2)
<a name="l226"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l227"></a>
<a name="l228"></a> x=yy1*zz2-zz1*yy2;
<a name="l229"></a> y=-xx1*zz2+zz1*xx2;
<a name="l230"></a> z=xx1*yy2-yy1*xx2;
<a name="l231"></a> </span><span class=cF1>if</span><span class=cF0> (dc-&gt;flags &amp; </span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l232"></a> r=dc-&gt;r;
<a name="l233"></a> xx=x*r[0]+y*r[1]+z*r[2];
<a name="l234"></a> yy=x*r[4]+y*r[5]+z*r[6];
<a name="l235"></a> zz=x*r[8]+y*r[9]+z*r[10];
<a name="l236"></a> x=xx; y=yy; z=zz;
<a name="l237"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l238"></a> </span><span class=cF1>if</span><span class=cF0> (d=</span><span class=cF5>Sqrt</span><span class=cF7>(</span><span class=cF5>Sqr</span><span class=cF0>(x)+</span><span class=cF5>Sqr</span><span class=cF0>(y)+</span><span class=cF5>Sqr</span><span class=cF0>(z)</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l239"></a> d=</span><span class=cF3>GR_SCALE</span><span class=cF0>/d;
<a name="l240"></a> dc-&gt;sym.snx = d*x;
<a name="l241"></a> dc-&gt;sym.sny = d*y;
<a name="l242"></a> dc-&gt;sym.snz = d*z;
<a name="l243"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l244"></a> </span><span class=cF1>if</span><span class=cF0> (dc-&gt;flags &amp; </span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>)
<a name="l245"></a> (*dc-&gt;transform)(dc,&amp;x1,&amp;y1,&amp;z1);
<a name="l246"></a> dc-&gt;sym.sx=x1;
<a name="l247"></a> dc-&gt;sym.sy=y1;
<a name="l248"></a> dc-&gt;sym.sz=z1;
<a name="l249"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l250"></a>}
<a name="l251"></a>
<a name="l252"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DCReflect</span><span class=cF0>(</span><span class=cF9>CDC</span><span class=cF0> *dc,</span><span class=cF9>I64</span><span class=cF0> *_x,</span><span class=cF9>I64</span><span class=cF0> *_y,</span><span class=cF9>I64</span><span class=cF0> *_z)
<a name="l253"></a>{</span><span class=cF2>//Reflect 3D point about device context's symmetry. Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.HTML#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
<a name="l254"></a> </span><span class=cF9>I64</span><span class=cF0> x=*_x&lt;&lt;32,y=*_y&lt;&lt;32,z=*_z&lt;&lt;32,
<a name="l255"></a> xx=*_x-dc-&gt;sym.sx,yy=*_y-dc-&gt;sym.sy,zz=*_z-dc-&gt;sym.sz,
<a name="l256"></a> d=(xx*dc-&gt;sym.snx+yy*dc-&gt;sym.sny+zz*dc-&gt;sym.snz)&gt;&gt;16,
<a name="l257"></a> xn,yn,zn,xx2,yy2,zz2;
<a name="l258"></a> xn=d*dc-&gt;sym.snx&gt;&gt;15;
<a name="l259"></a> yn=d*dc-&gt;sym.sny&gt;&gt;15;
<a name="l260"></a> zn=d*dc-&gt;sym.snz&gt;&gt;15;
<a name="l261"></a> xx=x-xn;
<a name="l262"></a> yy=y-yn;
<a name="l263"></a> zz=z-zn;
<a name="l264"></a> xx2=x+xn;
<a name="l265"></a> yy2=y+yn;
<a name="l266"></a> zz2=z+zn;
<a name="l267"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>xx&gt;&gt;16 -dc-&gt;sym.sx&lt;&lt;16</span><span class=cF7>)</span><span class=cF0>+
<a name="l268"></a> </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>yy&gt;&gt;16 -dc-&gt;sym.sy&lt;&lt;16</span><span class=cF7>)</span><span class=cF0>+
<a name="l269"></a> </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>zz&gt;&gt;16 -dc-&gt;sym.sz&lt;&lt;16</span><span class=cF7>)</span><span class=cF0>&lt;
<a name="l270"></a> </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>xx2&gt;&gt;16-dc-&gt;sym.sx&lt;&lt;16</span><span class=cF7>)</span><span class=cF0>+
<a name="l271"></a> </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>yy2&gt;&gt;16-dc-&gt;sym.sy&lt;&lt;16</span><span class=cF7>)</span><span class=cF0>+
<a name="l272"></a> </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>zz2&gt;&gt;16-dc-&gt;sym.sz&lt;&lt;16</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l273"></a> *_x=xx.i32[1]; *_y=yy.i32[1]; *_z=zz.i32[1];
<a name="l274"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l275"></a> *_x=xx2.i32[1]; *_y=yy2.i32[1]; *_z=zz2.i32[1];
<a name="l276"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l277"></a>}
<a name="l278"></a>
<a name="l279"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Graphics/Math&quot;</span><span class=cF0>
<a name="l280"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> 24
<a name="l281"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0> 8
<a name="l282"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Circle</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *aux_data,</span><span class=cF9>I64</span><span class=cF0> cx,</span><span class=cF9>I64</span><span class=cF0> cy,</span><span class=cF9>I64</span><span class=cF0> cz,</span><span class=cF9>I64</span><span class=cF0> radius,
<a name="l283"></a> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *aux,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z</span><span class=cF7>)</span><span class=cF0>,
<a name="l284"></a> </span><span class=cF9>I64</span><span class=cF0> step=1,</span><span class=cF1>F64</span><span class=cF0> start_radians=0,</span><span class=cF1>F64</span><span class=cF0> len_radians=2*</span><span class=cF3>pi</span><span class=cF0>)
<a name="l285"></a>{</span><span class=cF2>//Step through circle arc calling callback.</span><span class=cF0>
<a name="l286"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,len=</span><span class=cF5>Ceil</span><span class=cF0>(len_radians*radius),
<a name="l287"></a> x,y,x1,y1,s1,s2,c;
<a name="l288"></a> </span><span class=cF1>F64</span><span class=cF0> t;
<a name="l289"></a> </span><span class=cF1>if</span><span class=cF0> (radius&lt;=0||!step) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l290"></a> t=1.0/radius;
<a name="l291"></a> c=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Cos</span><span class=cF0>(t);
<a name="l292"></a> </span><span class=cF1>if</span><span class=cF0> (step&lt;0) </span><span class=cF7>{</span><span class=cF0>
<a name="l293"></a> step=-step;
<a name="l294"></a> s2=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Sin</span><span class=cF0>(t);
<a name="l295"></a> s1=-s2;
<a name="l296"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l297"></a> s1=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Sin</span><span class=cF0>(t);
<a name="l298"></a> s2=-s1;
<a name="l299"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l300"></a> </span><span class=cF1>if</span><span class=cF0> (start_radians) </span><span class=cF7>{</span><span class=cF0>
<a name="l301"></a> x=radius*</span><span class=cF5>Cos</span><span class=cF0>(start_radians);
<a name="l302"></a> y=-radius*</span><span class=cF5>Sin</span><span class=cF0>(start_radians);
<a name="l303"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l304"></a> x=radius;
<a name="l305"></a> y=0;
<a name="l306"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l307"></a> x&lt;&lt;=</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l308"></a> y&lt;&lt;=</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l309"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;=len;i+=step) </span><span class=cF7>{</span><span class=cF0>
<a name="l310"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,cx+x&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>,cy+y&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>,cz</span><span class=cF7>)</span><span class=cF0>)
<a name="l311"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l312"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;step;j++) {
<a name="l313"></a> x1=(c*x+s1*y)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l314"></a> y1=(s2*x+c*y)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l315"></a> x=x1; y=y1;
<a name="l316"></a> }
<a name="l317"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l318"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l319"></a>}
<a name="l320"></a>
<a name="l321"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Ellipse</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *aux_data,</span><span class=cF9>I64</span><span class=cF0> cx,</span><span class=cF9>I64</span><span class=cF0> cy,</span><span class=cF9>I64</span><span class=cF0> cz,
<a name="l322"></a> </span><span class=cF9>I64</span><span class=cF0> x_radius,</span><span class=cF9>I64</span><span class=cF0> y_radius,</span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *aux,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z</span><span class=cF7>)</span><span class=cF0>,
<a name="l323"></a> </span><span class=cF1>F64</span><span class=cF0> rot_angle=0,</span><span class=cF9>I64</span><span class=cF0> step=1,</span><span class=cF1>F64</span><span class=cF0> start_radians=0,</span><span class=cF1>F64</span><span class=cF0> len_radians=2*</span><span class=cF3>pi</span><span class=cF0>)
<a name="l324"></a>{</span><span class=cF2>//Step through ellipse arc calling callback.</span><span class=cF0>
<a name="l325"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,len,
<a name="l326"></a> x,y,_x,_y,x1,y1,x2,y2, s1,s2,c, s12,s22,c2;
<a name="l327"></a> </span><span class=cF1>F64</span><span class=cF0> t;
<a name="l328"></a> </span><span class=cF1>Bool</span><span class=cF0> first=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l329"></a> </span><span class=cF1>if</span><span class=cF0> (x_radius&lt;=0 || y_radius&lt;=0 || !step)
<a name="l330"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l331"></a> </span><span class=cF1>if</span><span class=cF0> (x_radius&gt;=y_radius) </span><span class=cF7>{</span><span class=cF0>
<a name="l332"></a> t=1.0/x_radius;
<a name="l333"></a> len=</span><span class=cF5>Ceil</span><span class=cF0>(len_radians*x_radius);
<a name="l334"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l335"></a> t=1.0/y_radius;
<a name="l336"></a> len=</span><span class=cF5>Ceil</span><span class=cF0>(len_radians*y_radius);
<a name="l337"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l338"></a>
<a name="l339"></a> c=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Cos</span><span class=cF0>(t);
<a name="l340"></a> </span><span class=cF1>if</span><span class=cF0> (step&lt;0) </span><span class=cF7>{</span><span class=cF0>
<a name="l341"></a> step=-step;
<a name="l342"></a> s2=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Sin</span><span class=cF0>(t);
<a name="l343"></a> s1=-s2;
<a name="l344"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l345"></a> s1=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Sin</span><span class=cF0>(t);
<a name="l346"></a> s2=-s1;
<a name="l347"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l348"></a>
<a name="l349"></a> c2=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Cos</span><span class=cF0>(rot_angle);
<a name="l350"></a> s12=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Sin</span><span class=cF0>(rot_angle);
<a name="l351"></a> s22=-s12;
<a name="l352"></a>
<a name="l353"></a> </span><span class=cF1>if</span><span class=cF0> (start_radians) </span><span class=cF7>{</span><span class=cF0>
<a name="l354"></a> x=x_radius*</span><span class=cF5>Cos</span><span class=cF0>(start_radians);
<a name="l355"></a> y=-x_radius*</span><span class=cF5>Sin</span><span class=cF0>(start_radians);
<a name="l356"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l357"></a> x=x_radius;
<a name="l358"></a> y=0;
<a name="l359"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l360"></a> x&lt;&lt;=</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l361"></a> y&lt;&lt;=</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l362"></a> x2=x;
<a name="l363"></a> y2=y;
<a name="l364"></a>
<a name="l365"></a> y1=y2*y_radius/x_radius;
<a name="l366"></a> x=(c2*x2+s12*y1)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l367"></a> y=(s22*x2+c2*y1)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l368"></a>
<a name="l369"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;=len;i+=step) </span><span class=cF7>{</span><span class=cF0>
<a name="l370"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>x&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>!=_x || y&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>!=_y || first</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l371"></a> !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,cx+x&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>,cy+y&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>,cz</span><span class=cF7>)</span><span class=cF0>)
<a name="l372"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l373"></a>
<a name="l374"></a> _x=x&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>; _y=y&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>; first=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l375"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;step;j++) {
<a name="l376"></a> x1=(c*x2+s1*y2)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l377"></a> y1=(s2*x2+c*y2)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l378"></a> x2=x1;
<a name="l379"></a> y2=y1;
<a name="l380"></a> y1=y1*y_radius/x_radius;
<a name="l381"></a> x=(c2*x1+s12*y1)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l382"></a> y=(s22*x1+c2*y1)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l383"></a> }
<a name="l384"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l385"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l386"></a>}
<a name="l387"></a>
<a name="l388"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>RegPoly</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *aux_data,</span><span class=cF9>I64</span><span class=cF0> cx,</span><span class=cF9>I64</span><span class=cF0> cy,</span><span class=cF9>I64</span><span class=cF0> cz,
<a name="l389"></a> </span><span class=cF9>I64</span><span class=cF0> x_radius,</span><span class=cF9>I64</span><span class=cF0> y_radius,</span><span class=cF9>I64</span><span class=cF0> sides,
<a name="l390"></a> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *aux,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z</span><span class=cF7>)</span><span class=cF0>,
<a name="l391"></a> </span><span class=cF1>F64</span><span class=cF0> rot_angle=0,</span><span class=cF9>I64</span><span class=cF0> step=1,</span><span class=cF1>F64</span><span class=cF0> start_radians=0,</span><span class=cF1>F64</span><span class=cF0> len_radians=2*</span><span class=cF3>pi</span><span class=cF0>)
<a name="l392"></a>{</span><span class=cF2>//Step through regular polygon calling callback.</span><span class=cF0>
<a name="l393"></a> </span><span class=cF9>I64</span><span class=cF0> i,n,x,y,x1,y1,x2,y2,
<a name="l394"></a> xx1,yy1,xx2,yy2,
<a name="l395"></a> s1,s2,c, s12,s22,c2;
<a name="l396"></a> </span><span class=cF1>F64</span><span class=cF0> angle_step;
<a name="l397"></a>
<a name="l398"></a> </span><span class=cF1>if</span><span class=cF0> (sides&lt;=0 || x_radius&lt;=0 || y_radius&lt;=0)
<a name="l399"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l400"></a>
<a name="l401"></a> angle_step=2*</span><span class=cF3>pi</span><span class=cF0>/sides;
<a name="l402"></a> n=len_radians*sides/(2*</span><span class=cF3>pi</span><span class=cF0>);
<a name="l403"></a>
<a name="l404"></a> s1=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Sin</span><span class=cF0>(angle_step);
<a name="l405"></a> s2=-s1;
<a name="l406"></a> c=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Cos</span><span class=cF0>(angle_step);
<a name="l407"></a>
<a name="l408"></a> s12=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Sin</span><span class=cF0>(rot_angle);
<a name="l409"></a> s22=-s12;
<a name="l410"></a> c2=1&lt;&lt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>*</span><span class=cF5>Cos</span><span class=cF0>(rot_angle);
<a name="l411"></a>
<a name="l412"></a> </span><span class=cF1>if</span><span class=cF0> (start_radians) </span><span class=cF7>{</span><span class=cF0>
<a name="l413"></a> x=x_radius*</span><span class=cF5>Cos</span><span class=cF0>(start_radians);
<a name="l414"></a> y=-x_radius*</span><span class=cF5>Sin</span><span class=cF0>(start_radians);
<a name="l415"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l416"></a> x=x_radius;
<a name="l417"></a> y=0;
<a name="l418"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l419"></a> x&lt;&lt;=</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l420"></a> y&lt;&lt;=</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l421"></a> x2=x;
<a name="l422"></a> y2=y;
<a name="l423"></a>
<a name="l424"></a> y1=y2*y_radius/x_radius;
<a name="l425"></a> x=(c2*x2+s12*y1)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l426"></a> y=(s22*x2+c2*y1)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l427"></a>
<a name="l428"></a> xx1=cx+x&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l429"></a> yy1=cy+y&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l430"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;n;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l431"></a> x1=(c*x2+s1*y2)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l432"></a> y1=(s2*x2+c*y2)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l433"></a> x2=x1;
<a name="l434"></a> y2=y1;
<a name="l435"></a> y1=y1*y_radius/x_radius;
<a name="l436"></a> x=(c2*x1+s12*y1)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l437"></a> y=(s22*x1+c2*y1)&gt;&gt;</span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
<a name="l438"></a> xx2=cx+x&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l439"></a> yy2=cy+y&gt;&gt;</span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
<a name="l440"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Line</span><span class=cF7>(</span><span class=cF0>aux_data,xx1,yy1,cz,xx2,yy2,cz,fp_plot,step</span><span class=cF7>)</span><span class=cF0>)
<a name="l441"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l442"></a> xx1=xx2; yy1=yy2;
<a name="l443"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l444"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l445"></a>}
<a name="l446"></a>
<a name="l447"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Graphics/Data Types/D3I32;Math/Data Types/D3I32;Data Types/D3I32&quot;</span><span class=cF0>
<a name="l448"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>F64</span><span class=cF0> </span><span class=cF5>D3I32Dist</span><span class=cF0>(</span><span class=cF9>CD3I32</span><span class=cF0> *p1,</span><span class=cF9>CD3I32</span><span class=cF0> *p2)
<a name="l449"></a>{</span><span class=cF2>//Distance</span><span class=cF0>
<a name="l450"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p1-&gt;x-p2-&gt;x</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p1-&gt;y-p2-&gt;y</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p1-&gt;z-p2-&gt;z</span><span class=cF7>)</span><span class=cF0>);
<a name="l451"></a>}
<a name="l452"></a>
<a name="l453"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>D3I32DistSqr</span><span class=cF0>(</span><span class=cF9>CD3I32</span><span class=cF0> *p1,</span><span class=cF9>CD3I32</span><span class=cF0> *p2)
<a name="l454"></a>{</span><span class=cF2>//Distance Squared</span><span class=cF0>
<a name="l455"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>SqrI64</span><span class=cF0>(p1-&gt;x-p2-&gt;x)+</span><span class=cF5>SqrI64</span><span class=cF0>(p1-&gt;y-p2-&gt;y)+</span><span class=cF5>SqrI64</span><span class=cF0>(p1-&gt;z-p2-&gt;z);
<a name="l456"></a>}
<a name="l457"></a>
<a name="l458"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>F64</span><span class=cF0> </span><span class=cF5>D3I32Norm</span><span class=cF0>(</span><span class=cF9>CD3I32</span><span class=cF0> *p)
<a name="l459"></a>{</span><span class=cF2>//Norm</span><span class=cF0>
<a name="l460"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p-&gt;x</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p-&gt;y</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p-&gt;z</span><span class=cF7>)</span><span class=cF0>);
<a name="l461"></a>}
<a name="l462"></a>
<a name="l463"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>D3I32NormSqr</span><span class=cF0>(</span><span class=cF9>CD3I32</span><span class=cF0> *p)
<a name="l464"></a>{</span><span class=cF2>//Norm Squared</span><span class=cF0>
<a name="l465"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>SqrI64</span><span class=cF0>(p-&gt;x)+</span><span class=cF5>SqrI64</span><span class=cF0>(p-&gt;y)+</span><span class=cF5>SqrI64</span><span class=cF0>(p-&gt;z);
<a name="l466"></a>}
<a name="l467"></a>
<a name="l468"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Graphics/Math&quot;</span><span class=cF0>
<a name="l469"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Bezier2</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *aux_data,</span><span class=cF9>CD3I32</span><span class=cF0> *ctrl,
<a name="l470"></a> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *aux,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> first=</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l471"></a>{</span><span class=cF2>//Go in 2nd order bezier calling callback.</span><span class=cF0>
<a name="l472"></a> </span><span class=cF9>I64</span><span class=cF0> x,y,z,xx,yy,zz,dx,dy,dz,d_max;
<a name="l473"></a> </span><span class=cF1>F64</span><span class=cF0> x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z,
<a name="l474"></a> x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
<a name="l475"></a> x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
<a name="l476"></a> t,d=</span><span class=cF5>D3I32Dist</span><span class=cF0>(&amp;ctrl[0],&amp;ctrl[1])+
<a name="l477"></a> </span><span class=cF5>D3I32Dist</span><span class=cF0>(&amp;ctrl[1],&amp;ctrl[2])+
<a name="l478"></a> </span><span class=cF5>D3I32Dist</span><span class=cF0>(&amp;ctrl[2],&amp;ctrl[0]),
<a name="l479"></a> s=0.5/d,t1,t2;
<a name="l480"></a> xx=x0; yy=y0; zz=z0;
<a name="l481"></a> </span><span class=cF1>if</span><span class=cF0> (first &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,xx,yy,zz</span><span class=cF7>)</span><span class=cF0>)
<a name="l482"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l483"></a> </span><span class=cF1>for</span><span class=cF0> (t=0.0;t&lt;=1.0;t+=s) </span><span class=cF7>{</span><span class=cF0>
<a name="l484"></a> t1=t*(1.0-t);
<a name="l485"></a> t2=t*t;
<a name="l486"></a> x=x0+x1*t1+x2*t2;
<a name="l487"></a> y=y0+y1*t1+y2*t2;
<a name="l488"></a> z=z0+z1*t1+z2*t2;
<a name="l489"></a> dx=</span><span class=cF5>AbsI64</span><span class=cF0>(x-xx);
<a name="l490"></a> dy=</span><span class=cF5>AbsI64</span><span class=cF0>(y-yy);
<a name="l491"></a> dz=</span><span class=cF5>AbsI64</span><span class=cF0>(z-zz);
<a name="l492"></a> </span><span class=cF1>if</span><span class=cF0> (dx&gt;dy)
<a name="l493"></a> d_max=dx;
<a name="l494"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l495"></a> d_max=dy;
<a name="l496"></a> </span><span class=cF1>if</span><span class=cF0> (dz&gt;d_max)
<a name="l497"></a> d_max=dz;
<a name="l498"></a> </span><span class=cF1>if</span><span class=cF0> (!d_max)
<a name="l499"></a> s*=1.1;
<a name="l500"></a> </span><span class=cF1>else</span><span class=cF0> {
<a name="l501"></a> s*=0.9;
<a name="l502"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,x,y,z</span><span class=cF7>)</span><span class=cF0>)
<a name="l503"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l504"></a> xx=x;yy=y;zz=z;
<a name="l505"></a> }
<a name="l506"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l507"></a> x=ctrl[2].x; y=ctrl[2].y; z=ctrl[2].z;
<a name="l508"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>xx!=x || yy!=y || zz!=z</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l509"></a> !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,x,y,z</span><span class=cF7>)</span><span class=cF0>)
<a name="l510"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l511"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l512"></a>}
<a name="l513"></a>
<a name="l514"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Bezier3</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *aux_data,</span><span class=cF9>CD3I32</span><span class=cF0> *ctrl,
<a name="l515"></a> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *aux,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> first=</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l516"></a>{</span><span class=cF2>//Go in 3rd order bezier calling callback.</span><span class=cF0>
<a name="l517"></a> </span><span class=cF9>I64</span><span class=cF0> x,y,z,xx,yy,zz,dx,dy,dz,d_max;
<a name="l518"></a> </span><span class=cF1>F64</span><span class=cF0> x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z,
<a name="l519"></a> x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
<a name="l520"></a> x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
<a name="l521"></a> x3=ctrl[3].x-x0,y3=ctrl[3].y-y0,z3=ctrl[3].z-z0,
<a name="l522"></a> t,d=</span><span class=cF5>D3I32Dist</span><span class=cF0>(&amp;ctrl[0],&amp;ctrl[1])+
<a name="l523"></a> </span><span class=cF5>D3I32Dist</span><span class=cF0>(&amp;ctrl[1],&amp;ctrl[2])+
<a name="l524"></a> </span><span class=cF5>D3I32Dist</span><span class=cF0>(&amp;ctrl[2],&amp;ctrl[3])+
<a name="l525"></a> </span><span class=cF5>D3I32Dist</span><span class=cF0>(&amp;ctrl[3],&amp;ctrl[0]),
<a name="l526"></a> s=0.5/d,nt,t1,t2,t3;
<a name="l527"></a> xx=x0; yy=y0; zz=z0;
<a name="l528"></a> </span><span class=cF1>if</span><span class=cF0> (first &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,xx,yy,zz</span><span class=cF7>)</span><span class=cF0>)
<a name="l529"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l530"></a> </span><span class=cF1>for</span><span class=cF0> (t=0.0;t&lt;=1.0;t+=s) </span><span class=cF7>{</span><span class=cF0>
<a name="l531"></a> nt=1.0-t;
<a name="l532"></a> t1=t*nt*nt;
<a name="l533"></a> t2=t*t*nt;
<a name="l534"></a> t3=t*t*t;
<a name="l535"></a> x=x0+x1*t1+x2*t2+x3*t3;
<a name="l536"></a> y=y0+y1*t1+y2*t2+y3*t3;
<a name="l537"></a> z=z0+z1*t1+z2*t2+z3*t3;
<a name="l538"></a> dx=</span><span class=cF5>AbsI64</span><span class=cF0>(x-xx);
<a name="l539"></a> dy=</span><span class=cF5>AbsI64</span><span class=cF0>(y-yy);
<a name="l540"></a> dz=</span><span class=cF5>AbsI64</span><span class=cF0>(z-zz);
<a name="l541"></a> </span><span class=cF1>if</span><span class=cF0> (dx&gt;dy)
<a name="l542"></a> d_max=dx;
<a name="l543"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l544"></a> d_max=dy;
<a name="l545"></a> </span><span class=cF1>if</span><span class=cF0> (dz&gt;d_max)
<a name="l546"></a> d_max=dz;
<a name="l547"></a> </span><span class=cF1>if</span><span class=cF0> (!d_max)
<a name="l548"></a> s*=1.1;
<a name="l549"></a> </span><span class=cF1>else</span><span class=cF0> {
<a name="l550"></a> s*=0.9;
<a name="l551"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,x,y,z</span><span class=cF7>)</span><span class=cF0>)
<a name="l552"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l553"></a> xx=x;yy=y;zz=z;
<a name="l554"></a> }
<a name="l555"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l556"></a> x=ctrl[3].x; y=ctrl[3].y; z=ctrl[3].z;
<a name="l557"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>xx!=x || yy!=y || zz!=z</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l558"></a> !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data,x,y,z</span><span class=cF7>)</span><span class=cF0>)
<a name="l559"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l560"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l561"></a>}
<a name="l562"></a>
<a name="l563"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>BSpline2</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *aux_data,</span><span class=cF9>CD3I32</span><span class=cF0> *ctrl,</span><span class=cF9>I64</span><span class=cF0> cnt,
<a name="l564"></a> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *aux,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> closed=</span><span class=cF3>FALSE</span><span class=cF0>)
<a name="l565"></a>{</span><span class=cF2>//Go in 2nd order spline calling callback.</span><span class=cF0>
<a name="l566"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
<a name="l567"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *c;
<a name="l568"></a> </span><span class=cF1>Bool</span><span class=cF0> first;
<a name="l569"></a> </span><span class=cF1>if</span><span class=cF0> (cnt&lt;3) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l570"></a> first=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l571"></a> </span><span class=cF1>if</span><span class=cF0> (closed) </span><span class=cF7>{</span><span class=cF0>
<a name="l572"></a> cnt++;
<a name="l573"></a> c=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF7>(</span><span class=cF0>cnt*2-1</span><span class=cF7>)</span><span class=cF0>);
<a name="l574"></a> j=1;
<a name="l575"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt-2;i++) {
<a name="l576"></a> c[j].x=(ctrl[i].x+ctrl[i+1].x)/2.0;
<a name="l577"></a> c[j].y=(ctrl[i].y+ctrl[i+1].y)/2.0;
<a name="l578"></a> c[j].z=(ctrl[i].z+ctrl[i+1].z)/2.0;
<a name="l579"></a> j+=2;
<a name="l580"></a> }
<a name="l581"></a> c[j].x=(ctrl[0].x+ctrl[cnt-2].x)/2.0;
<a name="l582"></a> c[j].y=(ctrl[0].y+ctrl[cnt-2].y)/2.0;
<a name="l583"></a> c[j].z=(ctrl[0].z+ctrl[cnt-2].z)/2.0;
<a name="l584"></a>
<a name="l585"></a> c[0].x=(c[1].x+c[j].x)/2.0;
<a name="l586"></a> c[0].y=(c[1].y+c[j].y)/2.0;
<a name="l587"></a> c[0].z=(c[1].z+c[j].z)/2.0;
<a name="l588"></a> j=2;
<a name="l589"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt-2;i++) {
<a name="l590"></a> c[j].x=(c[j-1].x+c[j+1].x)/2.0;
<a name="l591"></a> c[j].y=(c[j-1].y+c[j+1].y)/2.0;
<a name="l592"></a> c[j].z=(c[j-1].z+c[j+1].z)/2.0;
<a name="l593"></a> j+=2;
<a name="l594"></a> }
<a name="l595"></a> c[j].x=c[0].x;
<a name="l596"></a> c[j].y=c[0].y;
<a name="l597"></a> c[j].z=c[0].z;
<a name="l598"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l599"></a> c=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF7>(</span><span class=cF0>cnt*2-1</span><span class=cF7>)</span><span class=cF0>);
<a name="l600"></a> c[0].x=ctrl[0].x;
<a name="l601"></a> c[0].y=ctrl[0].y;
<a name="l602"></a> c[0].z=ctrl[0].z;
<a name="l603"></a> c[cnt*2-2].x=ctrl[cnt-1].x;
<a name="l604"></a> c[cnt*2-2].y=ctrl[cnt-1].y;
<a name="l605"></a> c[cnt*2-2].z=ctrl[cnt-1].z;
<a name="l606"></a> j=1;
<a name="l607"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt-1;i++) {
<a name="l608"></a> c[j].x=(ctrl[i].x+ctrl[i+1].x)/2.0;
<a name="l609"></a> c[j].y=(ctrl[i].y+ctrl[i+1].y)/2.0;
<a name="l610"></a> c[j].z=(ctrl[i].z+ctrl[i+1].z)/2.0;
<a name="l611"></a> j+=2;
<a name="l612"></a> }
<a name="l613"></a> j=2;
<a name="l614"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt-2;i++) {
<a name="l615"></a> c[j].x=(c[j-1].x+c[j+1].x)/2.0;
<a name="l616"></a> c[j].y=(c[j-1].y+c[j+1].y)/2.0;
<a name="l617"></a> c[j].z=(c[j-1].z+c[j+1].z)/2.0;
<a name="l618"></a> j+=2;
<a name="l619"></a> }
<a name="l620"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l621"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt*2-2;i+=2) </span><span class=cF7>{</span><span class=cF0>
<a name="l622"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bezier2</span><span class=cF7>(</span><span class=cF0>aux_data,&amp;c[i],fp_plot,first</span><span class=cF7>)</span><span class=cF0>)
<a name="l623"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l624"></a> first=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l625"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l626"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
<a name="l627"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l628"></a>}
<a name="l629"></a>
<a name="l630"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>BSpline3</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *aux_data,</span><span class=cF9>CD3I32</span><span class=cF0> *ctrl,</span><span class=cF9>I64</span><span class=cF0> cnt,
<a name="l631"></a> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF1>U8</span><span class=cF0> *aux,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0> z</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> closed=</span><span class=cF3>FALSE</span><span class=cF0>)
<a name="l632"></a>{</span><span class=cF2>//Go in 3rd order spline calling callback.</span><span class=cF0>
<a name="l633"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
<a name="l634"></a> </span><span class=cF1>F64</span><span class=cF0> x,y,z;
<a name="l635"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *c;
<a name="l636"></a> </span><span class=cF1>Bool</span><span class=cF0> first;
<a name="l637"></a> </span><span class=cF1>if</span><span class=cF0> (cnt&lt;3) </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l638"></a> first=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l639"></a> </span><span class=cF1>if</span><span class=cF0> (closed) </span><span class=cF7>{</span><span class=cF0>
<a name="l640"></a> cnt++;
<a name="l641"></a> c=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF7>(</span><span class=cF0>cnt*3-2</span><span class=cF7>)</span><span class=cF0>);
<a name="l642"></a> j=1;
<a name="l643"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt-2;i++) {
<a name="l644"></a> x=ctrl[i].x;
<a name="l645"></a> y=ctrl[i].y;
<a name="l646"></a> z=ctrl[i].z;
<a name="l647"></a> c[j].x=(ctrl[i+1].x-x)/3.0+x;
<a name="l648"></a> c[j].y=(ctrl[i+1].y-y)/3.0+y;
<a name="l649"></a> c[j].z=(ctrl[i+1].z-z)/3.0+z;
<a name="l650"></a> j++;
<a name="l651"></a> c[j].x=2.0*(ctrl[i+1].x-x)/3.0+x;
<a name="l652"></a> c[j].y=2.0*(ctrl[i+1].y-y)/3.0+y;
<a name="l653"></a> c[j].z=2.0*(ctrl[i+1].z-z)/3.0+z;
<a name="l654"></a> j+=2;
<a name="l655"></a> }
<a name="l656"></a> x=ctrl[cnt-2].x;
<a name="l657"></a> y=ctrl[cnt-2].y;
<a name="l658"></a> z=ctrl[cnt-2].z;
<a name="l659"></a> c[j].x=(ctrl[0].x-x)/3.0+x;
<a name="l660"></a> c[j].y=(ctrl[0].y-y)/3.0+y;
<a name="l661"></a> c[j].z=(ctrl[0].z-z)/3.0+z;
<a name="l662"></a> j++;
<a name="l663"></a> c[j].x=2.0*(ctrl[0].x-x)/3.0+x;
<a name="l664"></a> c[j].y=2.0*(ctrl[0].y-y)/3.0+y;
<a name="l665"></a> c[j].z=2.0*(ctrl[0].z-z)/3.0+z;
<a name="l666"></a>
<a name="l667"></a> c[0].x=(c[1].x+c[j].x)/2.0;
<a name="l668"></a> c[0].y=(c[1].y+c[j].y)/2.0;
<a name="l669"></a> c[0].z=(c[1].z+c[j].z)/2.0;
<a name="l670"></a>
<a name="l671"></a> j=3;
<a name="l672"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt-2;i++) {
<a name="l673"></a> c[j].x=(c[j-1].x+c[j+1].x)/2.0;
<a name="l674"></a> c[j].y=(c[j-1].y+c[j+1].y)/2.0;
<a name="l675"></a> c[j].z=(c[j-1].z+c[j+1].z)/2.0;
<a name="l676"></a> j+=3;
<a name="l677"></a> }
<a name="l678"></a> c[j].x=c[0].x;
<a name="l679"></a> c[j].y=c[0].y;
<a name="l680"></a> c[j].z=c[0].z;
<a name="l681"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l682"></a> c=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CD3I32</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF7>(</span><span class=cF0>cnt*3-2</span><span class=cF7>)</span><span class=cF0>);
<a name="l683"></a> c[0].x=ctrl[0].x;
<a name="l684"></a> c[0].y=ctrl[0].y;
<a name="l685"></a> c[0].z=ctrl[0].z;
<a name="l686"></a> c[cnt*3-3].x=ctrl[cnt-1].x;
<a name="l687"></a> c[cnt*3-3].y=ctrl[cnt-1].y;
<a name="l688"></a> c[cnt*3-3].z=ctrl[cnt-1].z;
<a name="l689"></a> j=1;
<a name="l690"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt-1;i++) {
<a name="l691"></a> x=ctrl[i].x;
<a name="l692"></a> y=ctrl[i].y;
<a name="l693"></a> z=ctrl[i].z;
<a name="l694"></a> c[j].x=(ctrl[i+1].x-x)/3.0+x;
<a name="l695"></a> c[j].y=(ctrl[i+1].y-y)/3.0+y;
<a name="l696"></a> c[j].z=(ctrl[i+1].z-z)/3.0+z;
<a name="l697"></a> j++;
<a name="l698"></a> c[j].x=2.0*(ctrl[i+1].x-x)/3.0+x;
<a name="l699"></a> c[j].y=2.0*(ctrl[i+1].y-y)/3.0+y;
<a name="l700"></a> c[j].z=2.0*(ctrl[i+1].z-z)/3.0+z;
<a name="l701"></a> j+=2;
<a name="l702"></a> }
<a name="l703"></a> j=3;
<a name="l704"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt-2;i++) {
<a name="l705"></a> c[j].x=(c[j-1].x+c[j+1].x)/2.0;
<a name="l706"></a> c[j].y=(c[j-1].y+c[j+1].y)/2.0;
<a name="l707"></a> c[j].z=(c[j-1].z+c[j+1].z)/2.0;
<a name="l708"></a> j+=3;
<a name="l709"></a> }
<a name="l710"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l711"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;cnt*3-3;i+=3) </span><span class=cF7>{</span><span class=cF0>
<a name="l712"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bezier3</span><span class=cF7>(</span><span class=cF0>aux_data,&amp;c[i],fp_plot,first</span><span class=cF7>)</span><span class=cF0>)
<a name="l713"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l714"></a> first=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l715"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l716"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
<a name="l717"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l718"></a>}
<a name="l719"></a>
<a name="l720"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>CC_LEFT</span><span class=cF0> 1
<a name="l721"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>CC_RIGHT</span><span class=cF0> 2
<a name="l722"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>CC_TOP</span><span class=cF0> 4
<a name="l723"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>CC_BOTTOM</span><span class=cF0> 8
<a name="l724"></a>
<a name="l725"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>ClipLine</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *_x1,</span><span class=cF9>I64</span><span class=cF0> *_y1,</span><span class=cF9>I64</span><span class=cF0> *_x2,</span><span class=cF9>I64</span><span class=cF0> *_y2,
<a name="l726"></a> </span><span class=cF9>I64</span><span class=cF0> left,</span><span class=cF9>I64</span><span class=cF0> top,</span><span class=cF9>I64</span><span class=cF0> right,</span><span class=cF9>I64</span><span class=cF0> bottom)
<a name="l727"></a>{</span><span class=cF2>//Clip x1,y1 x2,y2 with left,top,right,bottom.</span><span class=cF0>
<a name="l728"></a> </span><span class=cF9>I64</span><span class=cF0> x,y,x1=*_x1,y1=*_y1,x2=*_x2,y2=*_y2,
<a name="l729"></a> cc,cc1,cc2;
<a name="l730"></a> </span><span class=cF1>if</span><span class=cF0> (y1&gt;bottom)
<a name="l731"></a> cc1=</span><span class=cF3>CC_BOTTOM</span><span class=cF0>;
<a name="l732"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (y1&lt;top)
<a name="l733"></a> cc1=</span><span class=cF3>CC_TOP</span><span class=cF0>;
<a name="l734"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l735"></a> cc1=0;
<a name="l736"></a> </span><span class=cF1>if</span><span class=cF0> (x1&gt;right)
<a name="l737"></a> cc1|=</span><span class=cF3>CC_RIGHT</span><span class=cF0>;
<a name="l738"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x1&lt;left)
<a name="l739"></a> cc1|=</span><span class=cF3>CC_LEFT</span><span class=cF0>;
<a name="l740"></a>
<a name="l741"></a> </span><span class=cF1>if</span><span class=cF0> (y2&gt;bottom)
<a name="l742"></a> cc2=</span><span class=cF3>CC_BOTTOM</span><span class=cF0>;
<a name="l743"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (y2&lt;top)
<a name="l744"></a> cc2=</span><span class=cF3>CC_TOP</span><span class=cF0>;
<a name="l745"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l746"></a> cc2=0;
<a name="l747"></a> </span><span class=cF1>if</span><span class=cF0> (x2&gt;right)
<a name="l748"></a> cc2|=</span><span class=cF3>CC_RIGHT</span><span class=cF0>;
<a name="l749"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x2&lt;left)
<a name="l750"></a> cc2|=</span><span class=cF3>CC_LEFT</span><span class=cF0>;
<a name="l751"></a>
<a name="l752"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l753"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>cc1|cc2</span><span class=cF7>)</span><span class=cF0>)
<a name="l754"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l755"></a> </span><span class=cF1>if</span><span class=cF0> (cc1&amp;cc2)
<a name="l756"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l757"></a>
<a name="l758"></a> </span><span class=cF1>if</span><span class=cF0> (cc1)
<a name="l759"></a> cc=cc1;
<a name="l760"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l761"></a> cc=cc2;
<a name="l762"></a>
<a name="l763"></a> </span><span class=cF1>if</span><span class=cF0> (cc&amp;</span><span class=cF3>CC_BOTTOM</span><span class=cF0>) {
<a name="l764"></a> x=x1+(x2-x1)*(bottom-y1)/(y2-y1);
<a name="l765"></a> y=bottom;
<a name="l766"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (cc&amp;</span><span class=cF3>CC_TOP</span><span class=cF0>) {
<a name="l767"></a> x=x1+(x2-x1)*(top-y1)/(y2-y1);
<a name="l768"></a> y=top;
<a name="l769"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (cc&amp;</span><span class=cF3>CC_RIGHT</span><span class=cF0>) {
<a name="l770"></a> y=y1+(y2-y1)*(right-x1)/(x2-x1);
<a name="l771"></a> x=right;
<a name="l772"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l773"></a> y=y1+(y2-y1)*(left-x1)/(x2-x1);
<a name="l774"></a> x=left;
<a name="l775"></a> }
<a name="l776"></a>
<a name="l777"></a> </span><span class=cF1>if</span><span class=cF0> (cc==cc1) {
<a name="l778"></a> *_x1=x1=x;
<a name="l779"></a> *_y1=y1=y;
<a name="l780"></a> </span><span class=cF1>if</span><span class=cF0> (y1&gt;bottom)
<a name="l781"></a> cc1=</span><span class=cF3>CC_BOTTOM</span><span class=cF0>;
<a name="l782"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (y1&lt;top)
<a name="l783"></a> cc1=</span><span class=cF3>CC_TOP</span><span class=cF0>;
<a name="l784"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l785"></a> cc1=0;
<a name="l786"></a> </span><span class=cF1>if</span><span class=cF0> (x1&gt;right)
<a name="l787"></a> cc1|=</span><span class=cF3>CC_RIGHT</span><span class=cF0>;
<a name="l788"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x1&lt;left)
<a name="l789"></a> cc1|=</span><span class=cF3>CC_LEFT</span><span class=cF0>;
<a name="l790"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l791"></a> *_x2=x2=x;
<a name="l792"></a> *_y2=y2=y;
<a name="l793"></a> </span><span class=cF1>if</span><span class=cF0> (y2&gt;bottom)
<a name="l794"></a> cc2=</span><span class=cF3>CC_BOTTOM</span><span class=cF0>;
<a name="l795"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (y2&lt;top)
<a name="l796"></a> cc2=</span><span class=cF3>CC_TOP</span><span class=cF0>;
<a name="l797"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l798"></a> cc2=0;
<a name="l799"></a> </span><span class=cF1>if</span><span class=cF0> (x2&gt;right)
<a name="l800"></a> cc2|=</span><span class=cF3>CC_RIGHT</span><span class=cF0>;
<a name="l801"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x2&lt;left)
<a name="l802"></a> cc2|=</span><span class=cF3>CC_LEFT</span><span class=cF0>;
<a name="l803"></a> }
<a name="l804"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l805"></a>}
</span></pre></body>
</html>