mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
978 lines
114 KiB
HolyC
Executable file
978 lines
114 KiB
HolyC
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.05">
|
|
<style type="text/css">
|
|
body {background-color:#000000;}
|
|
.cF0{color:#ffffff;background-color:#000000;}
|
|
.cF1{color:#3465a4;background-color:#000000;}
|
|
.cF2{color:#4e9a06;background-color:#000000;}
|
|
.cF3{color:#06989a;background-color:#000000;}
|
|
.cF4{color:#a24444;background-color:#000000;}
|
|
.cF5{color:#75507b;background-color:#000000;}
|
|
.cF6{color:#ce982f;background-color:#000000;}
|
|
.cF7{color:#bcc0b9;background-color:#000000;}
|
|
.cF8{color:#555753;background-color:#000000;}
|
|
.cF9{color:#729fcf;background-color:#000000;}
|
|
.cFA{color:#82bc49;background-color:#000000;}
|
|
.cFB{color:#34e2e2;background-color:#000000;}
|
|
.cFC{color:#ac3535;background-color:#000000;}
|
|
.cFD{color:#ad7fa8;background-color:#000000;}
|
|
.cFE{color:#fce94f;background-color:#000000;}
|
|
.cFF{color:#000000;background-color:#000000;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/Math"</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>[</span><span class=cFE>8</span><span class=cF0>] = {-</span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>, -</span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>, -</span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>},
|
|
<a name="l4"></a> </span><span class=cFB>gr_y_offsets</span><span class=cF0>[</span><span class=cFE>8</span><span class=cF0>] = {-</span><span class=cFE>1</span><span class=cF0>, -</span><span class=cFE>1</span><span class=cF0>, -</span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>},
|
|
<a name="l5"></a> </span><span class=cFB>gr_x_offsets2</span><span class=cF0>[</span><span class=cFE>4</span><span class=cF0>] = { </span><span class=cFE>0</span><span class=cF0>, -</span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>},
|
|
<a name="l6"></a> </span><span class=cFB>gr_y_offsets2</span><span class=cF0>[</span><span class=cFE>4</span><span class=cF0>] = {-</span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>};
|
|
<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>,
|
|
<a name="l10"></a> </span><span class=cF9>I64</span><span class=cF0> step=</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF1>start</span><span class=cF0>=</span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l11"></a>{</span><span class=cF2>//Step through line segment calling callback.</span><span class=cF0>
|
|
<a name="l12"></a></span><span class=cF2>//Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l13"></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, 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>
|
|
<a name="l16"></a> </span><span class=cF1>if</span><span class=cF0> (adx >= ady)
|
|
<a name="l17"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (adx >= adz)
|
|
<a name="l19"></a> {
|
|
<a name="l20"></a> </span><span class=cF1>if</span><span class=cF0> (d = adx)
|
|
<a name="l21"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (dx >= </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l23"></a> dx = </span><span class=cFE>0x100000000</span><span class=cF0>;
|
|
<a name="l24"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l25"></a> dx = -</span><span class=cFE>0x100000000</span><span class=cF0>;
|
|
<a name="l26"></a> dy = dy << </span><span class=cFE>32</span><span class=cF0> / d;
|
|
<a name="l27"></a> dz = dz << </span><span class=cFE>32</span><span class=cF0> / d;
|
|
<a name="l28"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l29"></a> }
|
|
<a name="l30"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l31"></a> {
|
|
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (d = adz)
|
|
<a name="l33"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l34"></a> dx = dx << </span><span class=cFE>32</span><span class=cF0> / d;
|
|
<a name="l35"></a> dy = dy << </span><span class=cFE>32</span><span class=cF0> / d;
|
|
<a name="l36"></a> </span><span class=cF1>if</span><span class=cF0> (dz >= </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l37"></a> dz = </span><span class=cFE>0x100000000</span><span class=cF0>;
|
|
<a name="l38"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l39"></a> dz = -</span><span class=cFE>0x100000000</span><span class=cF0>;
|
|
<a name="l40"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l41"></a> }
|
|
<a name="l42"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l43"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l44"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l45"></a> </span><span class=cF1>if</span><span class=cF0> (ady >= adz)
|
|
<a name="l46"></a> {
|
|
<a name="l47"></a> </span><span class=cF1>if</span><span class=cF0> (d = ady)
|
|
<a name="l48"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l49"></a> dx = dx << </span><span class=cFE>32</span><span class=cF0> / d;
|
|
<a name="l50"></a> </span><span class=cF1>if</span><span class=cF0> (dy >= </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l51"></a> dy = </span><span class=cFE>0x100000000</span><span class=cF0>;
|
|
<a name="l52"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l53"></a> dy = -</span><span class=cFE>0x100000000</span><span class=cF0>;
|
|
<a name="l54"></a> dz = dz << </span><span class=cFE>32</span><span class=cF0> / d;
|
|
<a name="l55"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l56"></a> }
|
|
<a name="l57"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l58"></a> {
|
|
<a name="l59"></a> </span><span class=cF1>if</span><span class=cF0> (d = adz)
|
|
<a name="l60"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l61"></a> dx = dx << </span><span class=cFE>32</span><span class=cF0> / d;
|
|
<a name="l62"></a> dy = dy << </span><span class=cFE>32</span><span class=cF0> / d;
|
|
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (dz >= </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l64"></a> dz = </span><span class=cFE>0x100000000</span><span class=cF0>;
|
|
<a name="l65"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l66"></a> dz = -</span><span class=cFE>0x100000000</span><span class=cF0>;
|
|
<a name="l67"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l68"></a> }
|
|
<a name="l69"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l70"></a> x1 <<= </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l71"></a> y1 <<= </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l72"></a> z1 <<= </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l73"></a> </span><span class=cF1>for</span><span class=cF0> (j =</span><span class=cFE>0</span><span class=cF0>; j < </span><span class=cF1>start</span><span class=cF0>; j++)
|
|
<a name="l74"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l75"></a> x1 += dx;
|
|
<a name="l76"></a> y1 += dy;
|
|
<a name="l77"></a> z1 += dz;
|
|
<a name="l78"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l79"></a> </span><span class=cF1>if</span><span class=cF0> (step != </span><span class=cFE>1</span><span class=cF0> && step != </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l80"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l81"></a> dx *= step;
|
|
<a name="l82"></a> dy *= step;
|
|
<a name="l83"></a> dz *= step;
|
|
<a name="l84"></a> d /= step;
|
|
<a name="l85"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l86"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cF1>start</span><span class=cF0>; i <= d; i++)
|
|
<a name="l87"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l88"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>_x != x1.i32[</span><span class=cFE>1</span><span class=cF0>] || _y != y1.i32[</span><span class=cFE>1</span><span class=cF0>] || _z != z1.i32[</span><span class=cFE>1</span><span class=cF0>] || first</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l89"></a> !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data, x1.i32[</span><span class=cFE>1</span><span class=cF0>], y1.i32[</span><span class=cFE>1</span><span class=cF0>], z1.i32[</span><span class=cFE>1</span><span class=cF0>]</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l90"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l91"></a> first = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l92"></a> _x = x1.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l93"></a> _y = y1.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l94"></a> _z = z1.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l95"></a> x1 += dx; y1+=dy; z1+=dz;
|
|
<a name="l96"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (step == </span><span class=cFE>1</span><span class=cF0> && </span><span class=cF7>(</span><span class=cF0>_x != x2 || _y != y2 || _z != z2</span><span class=cF7>)</span><span class=cF0> && !</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="l98"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l99"></a>
|
|
<a name="l100"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l101"></a>}
|
|
<a name="l102"></a>
|
|
<a name="l103"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/Math/3D Transformation"</span><span class=cF0>
|
|
<a name="l104"></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="l105"></a>{</span><span class=cF2>//Multiply 4x4 matrices and store in dst. Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l106"></a></span><span class=cF2>//Conceptually, the transform m1 is applied after m2</span><span class=cF0>
|
|
<a name="l107"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, k;
|
|
<a name="l108"></a> </span><span class=cF1>F64</span><span class=cF0> sum;
|
|
<a name="l109"></a>
|
|
<a name="l110"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cFE>4</span><span class=cF0>; i++)
|
|
<a name="l111"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l112"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < </span><span class=cFE>4</span><span class=cF0>; j++)
|
|
<a name="l113"></a> {
|
|
<a name="l114"></a> sum = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l115"></a> </span><span class=cF1>for</span><span class=cF0> (k = </span><span class=cFE>0</span><span class=cF0>; k < </span><span class=cFE>4</span><span class=cF0>; k++)
|
|
<a name="l116"></a> sum += </span><span class=cF5>ToF64</span><span class=cF0>(m1[k + </span><span class=cFE>4</span><span class=cF0> * j]) * </span><span class=cF5>ToF64</span><span class=cF0>(m2[i + </span><span class=cFE>4</span><span class=cF0> * k]);
|
|
<a name="l117"></a> dst[i + </span><span class=cFE>4</span><span class=cF0> * j] = sum / </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l118"></a> }
|
|
<a name="l119"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l120"></a>
|
|
<a name="l121"></a> </span><span class=cF1>return</span><span class=cF0> dst;
|
|
<a name="l122"></a>}
|
|
<a name="l123"></a>
|
|
<a name="l124"></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="l125"></a>{</span><span class=cF2>//Multiply 4x4 matrices. Return MAlloced matrix. Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l126"></a></span><span class=cF2>//Conceptually, the transform m1 is applied after m2</span><span class=cF0>
|
|
<a name="l127"></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>) * </span><span class=cFE>16</span><span class=cF0>, mem_task</span><span class=cF7>)</span><span class=cF0>, m1, m2);
|
|
<a name="l128"></a>}
|
|
<a name="l129"></a>
|
|
<a name="l130"></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="l131"></a>{</span><span class=cF2>//Copy 4x4 Rot matrix.</span><span class=cF0>
|
|
<a name="l132"></a> </span><span class=cF5>MemCopy</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> * </span><span class=cFE>16</span><span class=cF0>);
|
|
<a name="l133"></a>
|
|
<a name="l134"></a> </span><span class=cF1>return</span><span class=cF0> dst;
|
|
<a name="l135"></a>}
|
|
<a name="l136"></a>
|
|
<a name="l137"></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="l138"></a>{</span><span class=cF2>//Return MAlloced copy of 4x4 Rot matrix.</span><span class=cF0>
|
|
<a name="l139"></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>) * </span><span class=cFE>16</span><span class=cF0>, mem_task</span><span class=cF7>)</span><span class=cF0>, src);
|
|
<a name="l140"></a>}
|
|
<a name="l141"></a>
|
|
<a name="l142"></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="l143"></a>{</span><span class=cF2>//Rot matrix about X axis. Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l144"></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="l145"></a> </span><span class=cF9>I64</span><span class=cF0> r[</span><span class=cFE>16</span><span class=cF0>], r2[</span><span class=cFE>16</span><span class=cF0>];
|
|
<a name="l146"></a>
|
|
<a name="l147"></a> </span><span class=cF5>MemSet</span><span class=cF0>(r, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>r</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l148"></a> r[</span><span class=cFE>5</span><span class=cF0>] = my_cos;
|
|
<a name="l149"></a> r[</span><span class=cFE>10</span><span class=cF0>] = my_cos;
|
|
<a name="l150"></a> r[</span><span class=cFE>9</span><span class=cF0>] = my_sin;
|
|
<a name="l151"></a> r[</span><span class=cFE>6</span><span class=cF0>] = -my_sin;
|
|
<a name="l152"></a> r[</span><span class=cFE>0</span><span class=cF0>] = </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l153"></a> r[</span><span class=cFE>15</span><span class=cF0>] = </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l154"></a>
|
|
<a name="l155"></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="l156"></a>}
|
|
<a name="l157"></a>
|
|
<a name="l158"></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="l159"></a>{</span><span class=cF2>//Rot matrix about Y axis. Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l160"></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="l161"></a> </span><span class=cF9>I64</span><span class=cF0> r[</span><span class=cFE>16</span><span class=cF0>], r2[</span><span class=cFE>16</span><span class=cF0>];
|
|
<a name="l162"></a>
|
|
<a name="l163"></a> </span><span class=cF5>MemSet</span><span class=cF0>(r, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>r</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l164"></a> r[</span><span class=cFE>0</span><span class=cF0>] = my_cos;
|
|
<a name="l165"></a> r[</span><span class=cFE>10</span><span class=cF0>] = my_cos;
|
|
<a name="l166"></a> r[</span><span class=cFE>8</span><span class=cF0>] = -my_sin;
|
|
<a name="l167"></a> r[</span><span class=cFE>2</span><span class=cF0>] = my_sin;
|
|
<a name="l168"></a> r[</span><span class=cFE>5</span><span class=cF0>] = </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l169"></a> r[</span><span class=cFE>15</span><span class=cF0>] = </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l170"></a>
|
|
<a name="l171"></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="l172"></a>}
|
|
<a name="l173"></a>
|
|
<a name="l174"></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="l175"></a>{</span><span class=cF2>//Rot matrix about Z axis. Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l176"></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="l177"></a> </span><span class=cF9>I64</span><span class=cF0> r[</span><span class=cFE>16</span><span class=cF0>], r2[</span><span class=cFE>16</span><span class=cF0>];
|
|
<a name="l178"></a>
|
|
<a name="l179"></a> </span><span class=cF5>MemSet</span><span class=cF0>(r, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>r</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l180"></a> r[</span><span class=cFE>0</span><span class=cF0>] = my_cos;
|
|
<a name="l181"></a> r[</span><span class=cFE>5</span><span class=cF0>] = my_cos;
|
|
<a name="l182"></a> r[</span><span class=cFE>4</span><span class=cF0>] = my_sin;
|
|
<a name="l183"></a> r[</span><span class=cFE>1</span><span class=cF0>] = -my_sin;
|
|
<a name="l184"></a> r[</span><span class=cFE>10</span><span class=cF0>] = </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l185"></a> r[</span><span class=cFE>15</span><span class=cF0>] = </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l186"></a>
|
|
<a name="l187"></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="l188"></a>}
|
|
<a name="l189"></a>
|
|
<a name="l190"></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="l191"></a>{</span><span class=cF2>//Scale 4x4 matrix by value.</span><span class=cF0>
|
|
<a name="l192"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l193"></a>
|
|
<a name="l194"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cFE>16</span><span class=cF0>; i++)
|
|
<a name="l195"></a> m[i] *= s;
|
|
<a name="l196"></a>
|
|
<a name="l197"></a> </span><span class=cF1>return</span><span class=cF0> m;
|
|
<a name="l198"></a>}
|
|
<a name="l199"></a>
|
|
<a name="l200"></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="l201"></a>{</span><span class=cF2>//Scale device context's thick by norm of transformation.</span><span class=cF0>
|
|
<a name="l202"></a> </span><span class=cF9>I64</span><span class=cF0> d;
|
|
<a name="l203"></a>
|
|
<a name="l204"></a> </span><span class=cF1>if</span><span class=cF0> (dc->flags & </span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>)
|
|
<a name="l205"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l206"></a> </span><span class=cF1>if</span><span class=cF0> (dc->thick)
|
|
<a name="l207"></a> {
|
|
<a name="l208"></a> d = dc->thick * dc->r_norm + </span><span class=cFE>0x80000000</span><span class=cF0>; </span><span class=cF2>//Round</span><span class=cF0>
|
|
<a name="l209"></a> dc->thick = d.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l210"></a> </span><span class=cF1>if</span><span class=cF0> (dc->thick < </span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l211"></a> dc->thick = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l212"></a> }
|
|
<a name="l213"></a> </span><span class=cF7>}</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=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="l217"></a>{</span><span class=cF2>//Set translation values in 4x4 matrix. Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l218"></a> r[</span><span class=cFE>0</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>] = x << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l219"></a> r[</span><span class=cFE>1</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>] = y << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l220"></a> r[</span><span class=cFE>2</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>] = z << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l221"></a> r[</span><span class=cFE>3</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>] = </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l222"></a>
|
|
<a name="l223"></a> </span><span class=cF1>return</span><span class=cF0> r;
|
|
<a name="l224"></a>}
|
|
<a name="l225"></a>
|
|
<a name="l226"></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="l227"></a>{</span><span class=cF2>//Add translation to 4x4 matrix. Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l228"></a> r[</span><span class=cFE>0</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>] += x << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l229"></a> r[</span><span class=cFE>1</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>] += y << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l230"></a> r[</span><span class=cFE>2</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>] += z << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l231"></a> r[</span><span class=cFE>3</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>] = </span><span class=cF3>GR_SCALE</span><span class=cF0>;
|
|
<a name="l232"></a>
|
|
<a name="l233"></a> </span><span class=cF1>return</span><span class=cF0> r;
|
|
<a name="l234"></a>}
|
|
<a name="l235"></a>
|
|
<a name="l236"></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="l237"></a>{</span><span class=cF2>//2D. Set device context's symmetry.</span><span class=cF0>
|
|
<a name="l238"></a> </span><span class=cF1>F64</span><span class=cF0> d;
|
|
<a name="l239"></a>
|
|
<a name="l240"></a> </span><span class=cF1>if</span><span class=cF0> (y1 == y2 && x1 == x2)
|
|
<a name="l241"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l242"></a> dc->sym.snx = y2 - y1;
|
|
<a name="l243"></a> dc->sym.sny = x1 - x2;
|
|
<a name="l244"></a> dc->sym.snz = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l245"></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->sym.snx) + </span><span class=cF5>SqrI64</span><span class=cF0>(dc->sym.sny) + </span><span class=cF5>SqrI64</span><span class=cF0>(dc->sym.snz)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l246"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l247"></a> d = </span><span class=cF3>GR_SCALE</span><span class=cF0> / d;
|
|
<a name="l248"></a> dc->sym.snx *= d;
|
|
<a name="l249"></a> dc->sym.sny *= d;
|
|
<a name="l250"></a> dc->sym.snz *= d;
|
|
<a name="l251"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l252"></a> dc->sym.sx = x1;
|
|
<a name="l253"></a> dc->sym.sy = y1;
|
|
<a name="l254"></a> dc->sym.sz = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l255"></a>
|
|
<a name="l256"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l257"></a>}
|
|
<a name="l258"></a>
|
|
<a name="l259"></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, </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="l260"></a>{</span><span class=cF2>//3D. Set device context's symmetry.</span><span class=cF0>
|
|
<a name="l261"></a> </span><span class=cF1>F64</span><span class=cF0> d, x, y, z, xx, yy, zz;
|
|
<a name="l262"></a> </span><span class=cF9>I64</span><span class=cF0> xx1, yy1, zz1, xx2, yy2, zz2, *r;
|
|
<a name="l263"></a>
|
|
<a name="l264"></a> xx1 = x1 - x2;
|
|
<a name="l265"></a> yy1 = y1 - y2;
|
|
<a name="l266"></a> zz1 = z1 - z2;
|
|
<a name="l267"></a> xx2 = x3 - x2;
|
|
<a name="l268"></a> yy2 = y3 - y2;
|
|
<a name="l269"></a> zz2 = z3 - z2;
|
|
<a name="l270"></a>
|
|
<a name="l271"></a> </span><span class=cF1>if</span><span class=cF0> (!xx1 && !yy1 && !zz1 || !xx2 && !yy2 && !zz2 || xx1 == xx2 && yy1 == yy2 && zz1 == zz2)
|
|
<a name="l272"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l273"></a>
|
|
<a name="l274"></a> x = yy1 * zz2 - zz1 * yy2;
|
|
<a name="l275"></a> y = -xx1 * zz2 + zz1 * xx2;
|
|
<a name="l276"></a> z = xx1 * yy2 - yy1 * xx2;
|
|
<a name="l277"></a> </span><span class=cF1>if</span><span class=cF0> (dc->flags & </span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>)
|
|
<a name="l278"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l279"></a> r = dc->r;
|
|
<a name="l280"></a> xx = x * r[</span><span class=cFE>0</span><span class=cF0>] + y * r[</span><span class=cFE>1</span><span class=cF0>] + z * r[</span><span class=cFE>2</span><span class=cF0>];
|
|
<a name="l281"></a> yy = x * r[</span><span class=cFE>4</span><span class=cF0>] + y * r[</span><span class=cFE>5</span><span class=cF0>] + z * r[</span><span class=cFE>6</span><span class=cF0>];
|
|
<a name="l282"></a> zz = x * r[</span><span class=cFE>8</span><span class=cF0>] + y * r[</span><span class=cFE>9</span><span class=cF0>] + z * r[</span><span class=cFE>10</span><span class=cF0>];
|
|
<a name="l283"></a> x = xx;
|
|
<a name="l284"></a> y = yy;
|
|
<a name="l285"></a> z = zz;
|
|
<a name="l286"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l287"></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>)
|
|
<a name="l288"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l289"></a> d = </span><span class=cF3>GR_SCALE</span><span class=cF0> / d;
|
|
<a name="l290"></a> dc->sym.snx = d * x;
|
|
<a name="l291"></a> dc->sym.sny = d * y;
|
|
<a name="l292"></a> dc->sym.snz = d * z;
|
|
<a name="l293"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l294"></a> </span><span class=cF1>if</span><span class=cF0> (dc->flags & </span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>)
|
|
<a name="l295"></a> (*dc->transform)(dc, &x1, &y1, &z1);
|
|
<a name="l296"></a> dc->sym.sx = x1;
|
|
<a name="l297"></a> dc->sym.sy = y1;
|
|
<a name="l298"></a> dc->sym.sz = z1;
|
|
<a name="l299"></a>
|
|
<a name="l300"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l301"></a>}
|
|
<a name="l302"></a>
|
|
<a name="l303"></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="l304"></a>{</span><span class=cF2>//Reflect 3D point about device context's symmetry. Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l305"></a> </span><span class=cF9>I64</span><span class=cF0> x = *_x << </span><span class=cFE>32</span><span class=cF0>,
|
|
<a name="l306"></a> y = *_y << </span><span class=cFE>32</span><span class=cF0>,
|
|
<a name="l307"></a> z = *_z << </span><span class=cFE>32</span><span class=cF0>,
|
|
<a name="l308"></a> xx = *_x - dc->sym.sx,
|
|
<a name="l309"></a> yy = *_y - dc->sym.sy,
|
|
<a name="l310"></a> zz = *_z - dc->sym.sz,
|
|
<a name="l311"></a> d = (xx * dc->sym.snx + yy * dc->sym.sny + zz * dc->sym.snz) >> </span><span class=cFE>16</span><span class=cF0>,
|
|
<a name="l312"></a> xn, yn, zn, xx2, yy2, zz2;
|
|
<a name="l313"></a>
|
|
<a name="l314"></a> xn = d * dc->sym.snx >> </span><span class=cFE>15</span><span class=cF0>;
|
|
<a name="l315"></a> yn = d * dc->sym.sny >> </span><span class=cFE>15</span><span class=cF0>;
|
|
<a name="l316"></a> zn = d * dc->sym.snz >> </span><span class=cFE>15</span><span class=cF0>;
|
|
<a name="l317"></a> xx = x - xn;
|
|
<a name="l318"></a> yy = y - yn;
|
|
<a name="l319"></a> zz = z - zn;
|
|
<a name="l320"></a> xx2 = x + xn;
|
|
<a name="l321"></a> yy2 = y + yn;
|
|
<a name="l322"></a> zz2 = z + zn;
|
|
<a name="l323"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>xx >> </span><span class=cFE>16</span><span class=cF0> - dc->sym.sx << </span><span class=cFE>16</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>yy >> </span><span class=cFE>16</span><span class=cF0> - dc->sym.sy << </span><span class=cFE>16</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>zz >> </span><span class=cFE>16</span><span class=cF0> - dc->sym.sz << </span><span class=cFE>16</span><span class=cF7>)</span><span class=cF0> <
|
|
<a name="l324"></a> </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>xx2 >> </span><span class=cFE>16</span><span class=cF0> - dc->sym.sx << </span><span class=cFE>16</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>yy2 >> </span><span class=cFE>16</span><span class=cF0> - dc->sym.sy << </span><span class=cFE>16</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>zz2 >> </span><span class=cFE>16</span><span class=cF0> - dc->sym.sz << </span><span class=cFE>16</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l325"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l326"></a> *_x = xx.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l327"></a> *_y = yy.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l328"></a> *_z = zz.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l329"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l330"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l331"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l332"></a> *_x = xx2.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l333"></a> *_y = yy2.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l334"></a> *_z = zz2.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l335"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l336"></a>}
|
|
<a name="l337"></a>
|
|
<a name="l338"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/Math"</span><span class=cF0>
|
|
<a name="l339"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> </span><span class=cFE>24</span><span class=cF0>
|
|
<a name="l340"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0> </span><span class=cFE>8</span><span class=cF0>
|
|
<a name="l341"></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, </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="l342"></a> </span><span class=cF9>I64</span><span class=cF0> step=</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> start_radians=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> len_radians=</span><span class=cFE>2</span><span class=cF0>*</span><span class=cF3>pi</span><span class=cF0>)
|
|
<a name="l343"></a>{</span><span class=cF2>//Step through circle arc calling callback.</span><span class=cF0>
|
|
<a name="l344"></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), x, y, x1, y1, s1, s2, c;
|
|
<a name="l345"></a> </span><span class=cF1>F64</span><span class=cF0> t;
|
|
<a name="l346"></a>
|
|
<a name="l347"></a> </span><span class=cF1>if</span><span class=cF0> (radius <= </span><span class=cFE>0</span><span class=cF0> || !step)
|
|
<a name="l348"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l349"></a> t = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / radius;
|
|
<a name="l350"></a> c = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(t);
|
|
<a name="l351"></a> </span><span class=cF1>if</span><span class=cF0> (step < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l352"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l353"></a> step = -step;
|
|
<a name="l354"></a> s2 = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(t);
|
|
<a name="l355"></a> s1 = -s2;
|
|
<a name="l356"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l357"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l358"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l359"></a> s1 = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(t);
|
|
<a name="l360"></a> s2 = -s1;
|
|
<a name="l361"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l362"></a> </span><span class=cF1>if</span><span class=cF0> (start_radians)
|
|
<a name="l363"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l364"></a> x = radius * </span><span class=cF5>Cos</span><span class=cF0>(start_radians);
|
|
<a name="l365"></a> y = -radius * </span><span class=cF5>Sin</span><span class=cF0>(start_radians);
|
|
<a name="l366"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l367"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l368"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l369"></a> x = radius;
|
|
<a name="l370"></a> y = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l371"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l372"></a> x <<= </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l373"></a> y <<= </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l374"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i <= len; i += step)
|
|
<a name="l375"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l376"></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 >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>, cy + y >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>, cz</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l377"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l378"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < step; j++)
|
|
<a name="l379"></a> {
|
|
<a name="l380"></a> x1 =(c * x + s1 * y) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l381"></a> y1 =(s2 * x + c * y) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l382"></a> x = x1;
|
|
<a name="l383"></a> y = y1;
|
|
<a name="l384"></a> }
|
|
<a name="l385"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l386"></a>
|
|
<a name="l387"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l388"></a>}
|
|
<a name="l389"></a>
|
|
<a name="l390"></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, </span><span class=cF9>I64</span><span class=cF0> x_radius, </span><span class=cF9>I64</span><span class=cF0> y_radius,
|
|
<a name="l391"></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>F64</span><span class=cF0> rot_angle=</span><span class=cFE>0</span><span class=cF0>,
|
|
<a name="l392"></a> </span><span class=cF9>I64</span><span class=cF0> step=</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> start_radians=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> len_radians=</span><span class=cFE>2</span><span class=cF0>*</span><span class=cF3>pi</span><span class=cF0>)
|
|
<a name="l393"></a>{</span><span class=cF2>//Step through ellipse arc calling callback.</span><span class=cF0>
|
|
<a name="l394"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, len, x, y, _x, _y, x1, y1, x2, y2, s1, s2, c, s12, s22, c2;
|
|
<a name="l395"></a> </span><span class=cF1>F64</span><span class=cF0> t;
|
|
<a name="l396"></a> </span><span class=cF1>Bool</span><span class=cF0> first = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l397"></a>
|
|
<a name="l398"></a> </span><span class=cF1>if</span><span class=cF0> (x_radius <= </span><span class=cFE>0</span><span class=cF0> || y_radius <= </span><span class=cFE>0</span><span class=cF0> || !step)
|
|
<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> </span><span class=cF1>if</span><span class=cF0> (x_radius >= y_radius)
|
|
<a name="l401"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l402"></a> t = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / x_radius;
|
|
<a name="l403"></a> len = </span><span class=cF5>Ceil</span><span class=cF0>(len_radians * x_radius);
|
|
<a name="l404"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l405"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l406"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l407"></a> t = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / y_radius;
|
|
<a name="l408"></a> len = </span><span class=cF5>Ceil</span><span class=cF0>(len_radians * y_radius);
|
|
<a name="l409"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l410"></a>
|
|
<a name="l411"></a> c = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(t);
|
|
<a name="l412"></a> </span><span class=cF1>if</span><span class=cF0> (step < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l413"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l414"></a> step = -step;
|
|
<a name="l415"></a> s2 =</span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(t);
|
|
<a name="l416"></a> s1 =-s2;
|
|
<a name="l417"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l418"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l419"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l420"></a> s1 = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(t);
|
|
<a name="l421"></a> s2 = -s1;
|
|
<a name="l422"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l423"></a>
|
|
<a name="l424"></a> c2 = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(rot_angle);
|
|
<a name="l425"></a> s12 = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(rot_angle);
|
|
<a name="l426"></a> s22 = -s12;
|
|
<a name="l427"></a>
|
|
<a name="l428"></a> </span><span class=cF1>if</span><span class=cF0> (start_radians)
|
|
<a name="l429"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l430"></a> x = x_radius * </span><span class=cF5>Cos</span><span class=cF0>(start_radians);
|
|
<a name="l431"></a> y = -x_radius * </span><span class=cF5>Sin</span><span class=cF0>(start_radians);
|
|
<a name="l432"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l433"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l434"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l435"></a> x = x_radius;
|
|
<a name="l436"></a> y = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l437"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l438"></a> x <<= </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l439"></a> y <<= </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l440"></a> x2 = x;
|
|
<a name="l441"></a> y2 = y;
|
|
<a name="l442"></a>
|
|
<a name="l443"></a> y1 = y2 * y_radius / x_radius;
|
|
<a name="l444"></a> x = (c2 * x2 + s12 * y1) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l445"></a> y = (s22 * x2 + c2 * y1) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l446"></a>
|
|
<a name="l447"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i <= len; i += step)
|
|
<a name="l448"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l449"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>x >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0> != _x || y >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0> != _y || first</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l450"></a> !</span><span class=cF7>(</span><span class=cF0>*fp_plot</span><span class=cF7>)(</span><span class=cF0>aux_data, cx + x >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>, cy + y >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>, cz</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l451"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l452"></a>
|
|
<a name="l453"></a> _x = x >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l454"></a> _y = y >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l455"></a> first = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l456"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < step; j++)
|
|
<a name="l457"></a> {
|
|
<a name="l458"></a> x1 = (c * x2 + s1 * y2) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l459"></a> y1 = (s2 * x2 + c * y2) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l460"></a> x2 = x1;
|
|
<a name="l461"></a> y2 = y1;
|
|
<a name="l462"></a> y1 = y1 * y_radius/x_radius;
|
|
<a name="l463"></a> x = (c2 * x1+ s12 * y1) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l464"></a> y = (s22 * x1 + c2 * y1) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l465"></a> }
|
|
<a name="l466"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l467"></a>
|
|
<a name="l468"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l469"></a>}
|
|
<a name="l470"></a>
|
|
<a name="l471"></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, </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="l472"></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="l473"></a> </span><span class=cF1>F64</span><span class=cF0> rot_angle=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> step=</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> start_radians=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> len_radians=</span><span class=cFE>2</span><span class=cF0>*</span><span class=cF3>pi</span><span class=cF0>)
|
|
<a name="l474"></a>{</span><span class=cF2>//Step through regular polygon calling callback.</span><span class=cF0>
|
|
<a name="l475"></a> </span><span class=cF9>I64</span><span class=cF0> i, n, x, y, x1, y1, x2, y2, xx1, yy1, xx2, yy2, s1, s2, c, s12, s22, c2;
|
|
<a name="l476"></a> </span><span class=cF1>F64</span><span class=cF0> angle_step;
|
|
<a name="l477"></a>
|
|
<a name="l478"></a> </span><span class=cF1>if</span><span class=cF0> (sides <= </span><span class=cFE>0</span><span class=cF0> || x_radius <= </span><span class=cFE>0</span><span class=cF0> || y_radius <= </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l479"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l480"></a>
|
|
<a name="l481"></a> angle_step = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0> / sides;
|
|
<a name="l482"></a> n = len_radians * sides / (</span><span class=cFE>2</span><span class=cF0> * </span><span class=cF3>pi</span><span class=cF0>);
|
|
<a name="l483"></a>
|
|
<a name="l484"></a> s1 = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(angle_step);
|
|
<a name="l485"></a> s2 = -s1;
|
|
<a name="l486"></a> c = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(angle_step);
|
|
<a name="l487"></a>
|
|
<a name="l488"></a> s12 = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(rot_angle);
|
|
<a name="l489"></a> s22 = -s12;
|
|
<a name="l490"></a> c2 = </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(rot_angle);
|
|
<a name="l491"></a>
|
|
<a name="l492"></a> </span><span class=cF1>if</span><span class=cF0> (start_radians)
|
|
<a name="l493"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l494"></a> x = x_radius * </span><span class=cF5>Cos</span><span class=cF0>(start_radians);
|
|
<a name="l495"></a> y = -x_radius * </span><span class=cF5>Sin</span><span class=cF0>(start_radians);
|
|
<a name="l496"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l497"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l498"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l499"></a> x = x_radius;
|
|
<a name="l500"></a> y = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l501"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l502"></a> x <<= </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l503"></a> y <<= </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l504"></a> x2 = x;
|
|
<a name="l505"></a> y2 = y;
|
|
<a name="l506"></a>
|
|
<a name="l507"></a> y1 = y2 * y_radius / x_radius;
|
|
<a name="l508"></a> x = (c2 * x2 + s12 * y1) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l509"></a> y = (s22 * x2 + c2 * y1) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l510"></a>
|
|
<a name="l511"></a> xx1 = cx + x >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l512"></a> yy1 = cy + y >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l513"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < n; i++)
|
|
<a name="l514"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l515"></a> x1 = (c * x2 + s1 * y2) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l516"></a> y1 = (s2 * x2 + c * y2) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l517"></a> x2 = x1;
|
|
<a name="l518"></a> y2 = y1;
|
|
<a name="l519"></a> y1 = y1 * y_radius / x_radius;
|
|
<a name="l520"></a> x = (c2 * x1 + s12 * y1) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l521"></a> y = (s22 * x1 + c2 * y1) >> </span><span class=cF3>GR_SCALE1_BITS</span><span class=cF0>;
|
|
<a name="l522"></a> xx2 = cx + x >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l523"></a> yy2 = cy + y >> </span><span class=cF3>GR_SCALE2_BITS</span><span class=cF0>;
|
|
<a name="l524"></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="l525"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l526"></a> xx1 = xx2;
|
|
<a name="l527"></a> yy1 = yy2;
|
|
<a name="l528"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l529"></a>
|
|
<a name="l530"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l531"></a>}
|
|
<a name="l532"></a>
|
|
<a name="l533"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/Data Types/D3I32;Math/Data Types/D3I32;Data Types/D3I32"</span><span class=cF0>
|
|
<a name="l534"></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="l535"></a>{</span><span class=cF2>//Distance</span><span class=cF0>
|
|
<a name="l536"></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->x - p2->x</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p1->y - p2->y</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p1->z - p2->z</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l537"></a>}
|
|
<a name="l538"></a>
|
|
<a name="l539"></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="l540"></a>{</span><span class=cF2>//Distance Squared</span><span class=cF0>
|
|
<a name="l541"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>SqrI64</span><span class=cF0>(p1->x - p2->x) + </span><span class=cF5>SqrI64</span><span class=cF0>(p1->y - p2->y) + </span><span class=cF5>SqrI64</span><span class=cF0>(p1->z - p2->z);
|
|
<a name="l542"></a>}
|
|
<a name="l543"></a>
|
|
<a name="l544"></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="l545"></a>{</span><span class=cF2>//Norm</span><span class=cF0>
|
|
<a name="l546"></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->x</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p->y</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>p->z</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l547"></a>}
|
|
<a name="l548"></a>
|
|
<a name="l549"></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="l550"></a>{</span><span class=cF2>//Norm Squared</span><span class=cF0>
|
|
<a name="l551"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>SqrI64</span><span class=cF0>(p->x) + </span><span class=cF5>SqrI64</span><span class=cF0>(p->y) + </span><span class=cF5>SqrI64</span><span class=cF0>(p->z);
|
|
<a name="l552"></a>}
|
|
<a name="l553"></a>
|
|
<a name="l554"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/Math"</span><span class=cF0>
|
|
<a name="l555"></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, </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="l556"></a>{</span><span class=cF2>//Go in 2nd order bezier calling callback.</span><span class=cF0>
|
|
<a name="l557"></a> </span><span class=cF9>I64</span><span class=cF0> x, y, z, xx, yy, zz, dx, dy, dz, d_max;
|
|
<a name="l558"></a> </span><span class=cF1>F64</span><span class=cF0> x0 = ctrl[</span><span class=cFE>0</span><span class=cF0>].x,
|
|
<a name="l559"></a> y0 = ctrl[</span><span class=cFE>0</span><span class=cF0>].y,
|
|
<a name="l560"></a> z0 = ctrl[</span><span class=cFE>0</span><span class=cF0>].z,
|
|
<a name="l561"></a> x1 = ctrl[</span><span class=cFE>1</span><span class=cF0>].x - x0,
|
|
<a name="l562"></a> y1 = ctrl[</span><span class=cFE>1</span><span class=cF0>].y - y0,
|
|
<a name="l563"></a> z1 = ctrl[</span><span class=cFE>1</span><span class=cF0>].z - z0,
|
|
<a name="l564"></a> x2 = ctrl[</span><span class=cFE>2</span><span class=cF0>].x - x0,
|
|
<a name="l565"></a> y2 = ctrl[</span><span class=cFE>2</span><span class=cF0>].y - y0,
|
|
<a name="l566"></a> z2 = ctrl[</span><span class=cFE>2</span><span class=cF0>].z - z0,
|
|
<a name="l567"></a> t, d = </span><span class=cF5>D3I32Dist</span><span class=cF0>(&ctrl[</span><span class=cFE>0</span><span class=cF0>], &ctrl[</span><span class=cFE>1</span><span class=cF0>]) + </span><span class=cF5>D3I32Dist</span><span class=cF0>(&ctrl[</span><span class=cFE>1</span><span class=cF0>], &ctrl[</span><span class=cFE>2</span><span class=cF0>]) + </span><span class=cF5>D3I32Dist</span><span class=cF0>(&ctrl[</span><span class=cFE>2</span><span class=cF0>], &ctrl[</span><span class=cFE>0</span><span class=cF0>]),
|
|
<a name="l568"></a> s = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> / d, t1, t2;
|
|
<a name="l569"></a>
|
|
<a name="l570"></a> xx = x0;
|
|
<a name="l571"></a> yy = y0;
|
|
<a name="l572"></a> zz = z0;
|
|
<a name="l573"></a> </span><span class=cF1>if</span><span class=cF0> (first && !</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="l574"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l575"></a> </span><span class=cF1>for</span><span class=cF0> (t = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>; t <= </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>; t += s)
|
|
<a name="l576"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l577"></a> t1 = t * (</span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> - t);
|
|
<a name="l578"></a> t2 = t * t;
|
|
<a name="l579"></a> x = x0 + x1 * t1 + x2 * t2;
|
|
<a name="l580"></a> y = y0 + y1 * t1 + y2 * t2;
|
|
<a name="l581"></a> z = z0 + z1 * t1 + z2 * t2;
|
|
<a name="l582"></a> dx = </span><span class=cF5>AbsI64</span><span class=cF0>(x - xx);
|
|
<a name="l583"></a> dy = </span><span class=cF5>AbsI64</span><span class=cF0>(y - yy);
|
|
<a name="l584"></a> dz = </span><span class=cF5>AbsI64</span><span class=cF0>(z - zz);
|
|
<a name="l585"></a> </span><span class=cF1>if</span><span class=cF0> (dx > dy)
|
|
<a name="l586"></a> d_max = dx;
|
|
<a name="l587"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l588"></a> d_max = dy;
|
|
<a name="l589"></a> </span><span class=cF1>if</span><span class=cF0> (dz > d_max)
|
|
<a name="l590"></a> d_max = dz;
|
|
<a name="l591"></a> </span><span class=cF1>if</span><span class=cF0> (!d_max)
|
|
<a name="l592"></a> s *= </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l593"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l594"></a> {
|
|
<a name="l595"></a> s *= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>9</span><span class=cF0>;
|
|
<a name="l596"></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="l597"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l598"></a> xx = x;
|
|
<a name="l599"></a> yy = y;
|
|
<a name="l600"></a> zz = z;
|
|
<a name="l601"></a> }
|
|
<a name="l602"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l603"></a> x = ctrl[</span><span class=cFE>2</span><span class=cF0>].x;
|
|
<a name="l604"></a> y = ctrl[</span><span class=cFE>2</span><span class=cF0>].y;
|
|
<a name="l605"></a> z = ctrl[</span><span class=cFE>2</span><span class=cF0>].z;
|
|
<a name="l606"></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> && !</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="l607"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l608"></a>
|
|
<a name="l609"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l610"></a>}
|
|
<a name="l611"></a>
|
|
<a name="l612"></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, </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="l613"></a>{</span><span class=cF2>//Go in 3rd order bezier calling callback.</span><span class=cF0>
|
|
<a name="l614"></a> </span><span class=cF9>I64</span><span class=cF0> x, y, z, xx, yy, zz, dx, dy, dz, d_max;
|
|
<a name="l615"></a> </span><span class=cF1>F64</span><span class=cF0> x0 = ctrl[</span><span class=cFE>0</span><span class=cF0>].x,
|
|
<a name="l616"></a> y0 = ctrl[</span><span class=cFE>0</span><span class=cF0>].y,
|
|
<a name="l617"></a> z0 = ctrl[</span><span class=cFE>0</span><span class=cF0>].z,
|
|
<a name="l618"></a> x1 = ctrl[</span><span class=cFE>1</span><span class=cF0>].x - x0,
|
|
<a name="l619"></a> y1 = ctrl[</span><span class=cFE>1</span><span class=cF0>].y - y0,
|
|
<a name="l620"></a> z1 = ctrl[</span><span class=cFE>1</span><span class=cF0>].z - z0,
|
|
<a name="l621"></a> x2 = ctrl[</span><span class=cFE>2</span><span class=cF0>].x - x0,
|
|
<a name="l622"></a> y2 = ctrl[</span><span class=cFE>2</span><span class=cF0>].y - y0,
|
|
<a name="l623"></a> z2 = ctrl[</span><span class=cFE>2</span><span class=cF0>].z - z0,
|
|
<a name="l624"></a> x3 = ctrl[</span><span class=cFE>3</span><span class=cF0>].x - x0,
|
|
<a name="l625"></a> y3 = ctrl[</span><span class=cFE>3</span><span class=cF0>].y - y0,
|
|
<a name="l626"></a> z3 = ctrl[</span><span class=cFE>3</span><span class=cF0>].z - z0,
|
|
<a name="l627"></a> t, d = </span><span class=cF5>D3I32Dist</span><span class=cF0>(&ctrl[</span><span class=cFE>0</span><span class=cF0>], &ctrl[</span><span class=cFE>1</span><span class=cF0>]) +
|
|
<a name="l628"></a> </span><span class=cF5>D3I32Dist</span><span class=cF0>(&ctrl[</span><span class=cFE>1</span><span class=cF0>], &ctrl[</span><span class=cFE>2</span><span class=cF0>]) +
|
|
<a name="l629"></a> </span><span class=cF5>D3I32Dist</span><span class=cF0>(&ctrl[</span><span class=cFE>2</span><span class=cF0>], &ctrl[</span><span class=cFE>3</span><span class=cF0>]) +
|
|
<a name="l630"></a> </span><span class=cF5>D3I32Dist</span><span class=cF0>(&ctrl[</span><span class=cFE>3</span><span class=cF0>], &ctrl[</span><span class=cFE>0</span><span class=cF0>]),
|
|
<a name="l631"></a> s = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> / d, nt, t1, t2, t3;
|
|
<a name="l632"></a>
|
|
<a name="l633"></a> xx = x0;
|
|
<a name="l634"></a> yy = y0;
|
|
<a name="l635"></a> zz = z0;
|
|
<a name="l636"></a> </span><span class=cF1>if</span><span class=cF0> (first && !</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="l637"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l638"></a> </span><span class=cF1>for</span><span class=cF0> (t = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>; t <= </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>; t += s)
|
|
<a name="l639"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l640"></a> nt = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> - t;
|
|
<a name="l641"></a> t1 = t * nt * nt;
|
|
<a name="l642"></a> t2 = t * t * nt;
|
|
<a name="l643"></a> t3 = t * t * t;
|
|
<a name="l644"></a> x = x0 + x1 * t1 + x2 * t2 + x3 * t3;
|
|
<a name="l645"></a> y = y0 + y1 * t1 + y2 * t2 + y3 * t3;
|
|
<a name="l646"></a> z = z0 + z1 * t1 + z2 * t2 + z3 * t3;
|
|
<a name="l647"></a> dx = </span><span class=cF5>AbsI64</span><span class=cF0>(x - xx);
|
|
<a name="l648"></a> dy = </span><span class=cF5>AbsI64</span><span class=cF0>(y - yy);
|
|
<a name="l649"></a> dz = </span><span class=cF5>AbsI64</span><span class=cF0>(z - zz);
|
|
<a name="l650"></a> </span><span class=cF1>if</span><span class=cF0> (dx > dy)
|
|
<a name="l651"></a> d_max = dx;
|
|
<a name="l652"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l653"></a> d_max = dy;
|
|
<a name="l654"></a> </span><span class=cF1>if</span><span class=cF0> (dz > d_max)
|
|
<a name="l655"></a> d_max = dz;
|
|
<a name="l656"></a> </span><span class=cF1>if</span><span class=cF0> (!d_max)
|
|
<a name="l657"></a> s *= </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l658"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l659"></a> {
|
|
<a name="l660"></a> s *= </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>9</span><span class=cF0>;
|
|
<a name="l661"></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="l662"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l663"></a> xx = x;
|
|
<a name="l664"></a> yy = y;
|
|
<a name="l665"></a> zz = z;
|
|
<a name="l666"></a> }
|
|
<a name="l667"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l668"></a> x = ctrl[</span><span class=cFE>3</span><span class=cF0>].x;
|
|
<a name="l669"></a> y = ctrl[</span><span class=cFE>3</span><span class=cF0>].y;
|
|
<a name="l670"></a> z = ctrl[</span><span class=cFE>3</span><span class=cF0>].z;
|
|
<a name="l671"></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> &&!</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="l672"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l673"></a>
|
|
<a name="l674"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l675"></a>}
|
|
<a name="l676"></a>
|
|
<a name="l677"></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> count, </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="l678"></a>{</span><span class=cF2>//Go in 2nd order spline calling callback.</span><span class=cF0>
|
|
<a name="l679"></a> </span><span class=cF9>I64</span><span class=cF0> i, j;
|
|
<a name="l680"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *c;
|
|
<a name="l681"></a> </span><span class=cF1>Bool</span><span class=cF0> first;
|
|
<a name="l682"></a>
|
|
<a name="l683"></a> </span><span class=cF1>if</span><span class=cF0> (count < </span><span class=cFE>3</span><span class=cF0>)
|
|
<a name="l684"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l685"></a> first = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l686"></a> </span><span class=cF1>if</span><span class=cF0> (closed)
|
|
<a name="l687"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l688"></a> count++;
|
|
<a name="l689"></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>count * </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l690"></a> j = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l691"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count - </span><span class=cFE>2</span><span class=cF0>; i++)
|
|
<a name="l692"></a> {
|
|
<a name="l693"></a> c[j].x = (ctrl[i].x + ctrl[i + </span><span class=cFE>1</span><span class=cF0>].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l694"></a> c[j].y = (ctrl[i].y + ctrl[i + </span><span class=cFE>1</span><span class=cF0>].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l695"></a> c[j].z = (ctrl[i].z + ctrl[i + </span><span class=cFE>1</span><span class=cF0>].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l696"></a> j += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l697"></a> }
|
|
<a name="l698"></a> c[j].x = (ctrl[</span><span class=cFE>0</span><span class=cF0>].x + ctrl[count - </span><span class=cFE>2</span><span class=cF0>].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l699"></a> c[j].y = (ctrl[</span><span class=cFE>0</span><span class=cF0>].y + ctrl[count - </span><span class=cFE>2</span><span class=cF0>].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l700"></a> c[j].z = (ctrl[</span><span class=cFE>0</span><span class=cF0>].z + ctrl[count - </span><span class=cFE>2</span><span class=cF0>].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l701"></a>
|
|
<a name="l702"></a> c[</span><span class=cFE>0</span><span class=cF0>].x = (c[</span><span class=cFE>1</span><span class=cF0>].x + c[j].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l703"></a> c[</span><span class=cFE>0</span><span class=cF0>].y = (c[</span><span class=cFE>1</span><span class=cF0>].y + c[j].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l704"></a> c[</span><span class=cFE>0</span><span class=cF0>].z = (c[</span><span class=cFE>1</span><span class=cF0>].z + c[j].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l705"></a> j = </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l706"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count - </span><span class=cFE>2</span><span class=cF0>; i++)
|
|
<a name="l707"></a> {
|
|
<a name="l708"></a> c[j].x = (c[j - </span><span class=cFE>1</span><span class=cF0>].x + c[j + </span><span class=cFE>1</span><span class=cF0>].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l709"></a> c[j].y = (c[j - </span><span class=cFE>1</span><span class=cF0>].y + c[j + </span><span class=cFE>1</span><span class=cF0>].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l710"></a> c[j].z = (c[j - </span><span class=cFE>1</span><span class=cF0>].z + c[j + </span><span class=cFE>1</span><span class=cF0>].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l711"></a> j += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l712"></a> }
|
|
<a name="l713"></a> c[j].x = c[</span><span class=cFE>0</span><span class=cF0>].x;
|
|
<a name="l714"></a> c[j].y = c[</span><span class=cFE>0</span><span class=cF0>].y;
|
|
<a name="l715"></a> c[j].z = c[</span><span class=cFE>0</span><span class=cF0>].z;
|
|
<a name="l716"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l717"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l718"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l719"></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>count * </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l720"></a> c[</span><span class=cFE>0</span><span class=cF0>].x = ctrl[</span><span class=cFE>0</span><span class=cF0>].x;
|
|
<a name="l721"></a> c[</span><span class=cFE>0</span><span class=cF0>].y = ctrl[</span><span class=cFE>0</span><span class=cF0>].y;
|
|
<a name="l722"></a> c[</span><span class=cFE>0</span><span class=cF0>].z = ctrl[</span><span class=cFE>0</span><span class=cF0>].z;
|
|
<a name="l723"></a> c[count * </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0>].x = ctrl[count - </span><span class=cFE>1</span><span class=cF0>].x;
|
|
<a name="l724"></a> c[count * </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0>].y = ctrl[count - </span><span class=cFE>1</span><span class=cF0>].y;
|
|
<a name="l725"></a> c[count * </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0>].z = ctrl[count - </span><span class=cFE>1</span><span class=cF0>].z;
|
|
<a name="l726"></a> j = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l727"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count - </span><span class=cFE>1</span><span class=cF0>; i++)
|
|
<a name="l728"></a> {
|
|
<a name="l729"></a> c[j].x = (ctrl[i].x + ctrl[i + </span><span class=cFE>1</span><span class=cF0>].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l730"></a> c[j].y = (ctrl[i].y + ctrl[i + </span><span class=cFE>1</span><span class=cF0>].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l731"></a> c[j].z = (ctrl[i].z + ctrl[i + </span><span class=cFE>1</span><span class=cF0>].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l732"></a> j += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l733"></a> }
|
|
<a name="l734"></a> j = </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l735"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count - </span><span class=cFE>2</span><span class=cF0>; i++)
|
|
<a name="l736"></a> {
|
|
<a name="l737"></a> c[j].x = (c[j - </span><span class=cFE>1</span><span class=cF0>].x + c[j + </span><span class=cFE>1</span><span class=cF0>].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l738"></a> c[j].y = (c[j - </span><span class=cFE>1</span><span class=cF0>].y + c[j + </span><span class=cFE>1</span><span class=cF0>].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l739"></a> c[j].z = (c[j - </span><span class=cFE>1</span><span class=cF0>].z + c[j + </span><span class=cFE>1</span><span class=cF0>].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l740"></a> j += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l741"></a> }
|
|
<a name="l742"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l743"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count * </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0>; i += </span><span class=cFE>2</span><span class=cF0>)
|
|
<a name="l744"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l745"></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, &c[i], fp_plot, first</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l746"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l747"></a> first = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l748"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l749"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
|
|
<a name="l750"></a>
|
|
<a name="l751"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l752"></a>}
|
|
<a name="l753"></a>
|
|
<a name="l754"></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> count, </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="l755"></a>{</span><span class=cF2>//Go in 3rd order spline calling callback.</span><span class=cF0>
|
|
<a name="l756"></a> </span><span class=cF9>I64</span><span class=cF0> i, j;
|
|
<a name="l757"></a> </span><span class=cF1>F64</span><span class=cF0> x, y, z;
|
|
<a name="l758"></a> </span><span class=cF9>CD3I32</span><span class=cF0> *c;
|
|
<a name="l759"></a> </span><span class=cF1>Bool</span><span class=cF0> first;
|
|
<a name="l760"></a>
|
|
<a name="l761"></a> </span><span class=cF1>if</span><span class=cF0> (count < </span><span class=cFE>3</span><span class=cF0>)
|
|
<a name="l762"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l763"></a> first = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l764"></a> </span><span class=cF1>if</span><span class=cF0> (closed)
|
|
<a name="l765"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l766"></a> count++;
|
|
<a name="l767"></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>count * </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l768"></a> j = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l769"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count - </span><span class=cFE>2</span><span class=cF0>; i++)
|
|
<a name="l770"></a> {
|
|
<a name="l771"></a> x = ctrl[i].x;
|
|
<a name="l772"></a> y = ctrl[i].y;
|
|
<a name="l773"></a> z = ctrl[i].z;
|
|
<a name="l774"></a> c[j].x = (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].x - x) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + x;
|
|
<a name="l775"></a> c[j].y = (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].y - y) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + y;
|
|
<a name="l776"></a> c[j].z = (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].z - z) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + z;
|
|
<a name="l777"></a> j++;
|
|
<a name="l778"></a> c[j].x = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].x - x) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + x;
|
|
<a name="l779"></a> c[j].y = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].y - y) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + y;
|
|
<a name="l780"></a> c[j].z = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].z - z) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + z;
|
|
<a name="l781"></a> j += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l782"></a> }
|
|
<a name="l783"></a> x = ctrl[count - </span><span class=cFE>2</span><span class=cF0>].x;
|
|
<a name="l784"></a> y = ctrl[count - </span><span class=cFE>2</span><span class=cF0>].y;
|
|
<a name="l785"></a> z = ctrl[count - </span><span class=cFE>2</span><span class=cF0>].z;
|
|
<a name="l786"></a> c[j].x = (ctrl[</span><span class=cFE>0</span><span class=cF0>].x - x) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + x;
|
|
<a name="l787"></a> c[j].y = (ctrl[</span><span class=cFE>0</span><span class=cF0>].y - y) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + y;
|
|
<a name="l788"></a> c[j].z = (ctrl[</span><span class=cFE>0</span><span class=cF0>].z - z) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + z;
|
|
<a name="l789"></a> j++;
|
|
<a name="l790"></a> c[j].x = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[</span><span class=cFE>0</span><span class=cF0>].x - x) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + x;
|
|
<a name="l791"></a> c[j].y = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[</span><span class=cFE>0</span><span class=cF0>].y - y) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + y;
|
|
<a name="l792"></a> c[j].z = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[</span><span class=cFE>0</span><span class=cF0>].z - z) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + z;
|
|
<a name="l793"></a>
|
|
<a name="l794"></a> c[</span><span class=cFE>0</span><span class=cF0>].x = (c[</span><span class=cFE>1</span><span class=cF0>].x + c[j].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l795"></a> c[</span><span class=cFE>0</span><span class=cF0>].y = (c[</span><span class=cFE>1</span><span class=cF0>].y + c[j].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l796"></a> c[</span><span class=cFE>0</span><span class=cF0>].z = (c[</span><span class=cFE>1</span><span class=cF0>].z + c[j].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l797"></a>
|
|
<a name="l798"></a> j = </span><span class=cFE>3</span><span class=cF0>;
|
|
<a name="l799"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count - </span><span class=cFE>2</span><span class=cF0>; i++)
|
|
<a name="l800"></a> {
|
|
<a name="l801"></a> c[j].x = (c[j - </span><span class=cFE>1</span><span class=cF0>].x + c[j + </span><span class=cFE>1</span><span class=cF0>].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l802"></a> c[j].y = (c[j - </span><span class=cFE>1</span><span class=cF0>].y + c[j + </span><span class=cFE>1</span><span class=cF0>].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l803"></a> c[j].z = (c[j - </span><span class=cFE>1</span><span class=cF0>].z + c[j + </span><span class=cFE>1</span><span class=cF0>].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l804"></a> j += </span><span class=cFE>3</span><span class=cF0>;
|
|
<a name="l805"></a> }
|
|
<a name="l806"></a> c[j].x = c[</span><span class=cFE>0</span><span class=cF0>].x;
|
|
<a name="l807"></a> c[j].y = c[</span><span class=cFE>0</span><span class=cF0>].y;
|
|
<a name="l808"></a> c[j].z = c[</span><span class=cFE>0</span><span class=cF0>].z;
|
|
<a name="l809"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l810"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l811"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l812"></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>count * </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l813"></a> c[</span><span class=cFE>0</span><span class=cF0>].x = ctrl[</span><span class=cFE>0</span><span class=cF0>].x;
|
|
<a name="l814"></a> c[</span><span class=cFE>0</span><span class=cF0>].y = ctrl[</span><span class=cFE>0</span><span class=cF0>].y;
|
|
<a name="l815"></a> c[</span><span class=cFE>0</span><span class=cF0>].z = ctrl[</span><span class=cFE>0</span><span class=cF0>].z;
|
|
<a name="l816"></a> c[count * </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0>].x = ctrl[count - </span><span class=cFE>1</span><span class=cF0>].x;
|
|
<a name="l817"></a> c[count * </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0>].y = ctrl[count - </span><span class=cFE>1</span><span class=cF0>].y;
|
|
<a name="l818"></a> c[count * </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0>].z = ctrl[count - </span><span class=cFE>1</span><span class=cF0>].z;
|
|
<a name="l819"></a> j = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l820"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count - </span><span class=cFE>1</span><span class=cF0>; i++)
|
|
<a name="l821"></a> {
|
|
<a name="l822"></a> x = ctrl[i].x;
|
|
<a name="l823"></a> y = ctrl[i].y;
|
|
<a name="l824"></a> z = ctrl[i].z;
|
|
<a name="l825"></a> c[j].x = (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].x - x) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + x;
|
|
<a name="l826"></a> c[j].y = (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].y - y) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + y;
|
|
<a name="l827"></a> c[j].z = (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].z - z) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + z;
|
|
<a name="l828"></a> j++;
|
|
<a name="l829"></a> c[j].x = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].x - x) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + x;
|
|
<a name="l830"></a> c[j].y = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].y - y) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + y;
|
|
<a name="l831"></a> c[j].z = </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * (ctrl[i + </span><span class=cFE>1</span><span class=cF0>].z - z) / </span><span class=cFE>3</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> + z;
|
|
<a name="l832"></a> j += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l833"></a> }
|
|
<a name="l834"></a> j = </span><span class=cFE>3</span><span class=cF0>;
|
|
<a name="l835"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count - </span><span class=cFE>2</span><span class=cF0>; i++)
|
|
<a name="l836"></a> {
|
|
<a name="l837"></a> c[j].x = (c[j - </span><span class=cFE>1</span><span class=cF0>].x + c[j + </span><span class=cFE>1</span><span class=cF0>].x) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l838"></a> c[j].y = (c[j - </span><span class=cFE>1</span><span class=cF0>].y + c[j + </span><span class=cFE>1</span><span class=cF0>].y) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l839"></a> c[j].z = (c[j - </span><span class=cFE>1</span><span class=cF0>].z + c[j + </span><span class=cFE>1</span><span class=cF0>].z) / </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l840"></a> j += </span><span class=cFE>3</span><span class=cF0>;
|
|
<a name="l841"></a> }
|
|
<a name="l842"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l843"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < count * </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0>; i += </span><span class=cFE>3</span><span class=cF0>)
|
|
<a name="l844"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l845"></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, &c[i], fp_plot, first</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l846"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l847"></a> first = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l848"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l849"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
|
|
<a name="l850"></a>
|
|
<a name="l851"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l852"></a>}
|
|
<a name="l853"></a>
|
|
<a name="l854"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>CC_LEFT</span><span class=cF0> </span><span class=cFE>1</span><span class=cF0>
|
|
<a name="l855"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>CC_RIGHT</span><span class=cF0> </span><span class=cFE>2</span><span class=cF0>
|
|
<a name="l856"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>CC_TOP</span><span class=cF0> </span><span class=cFE>4</span><span class=cF0>
|
|
<a name="l857"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>CC_BOTTOM</span><span class=cF0> </span><span class=cFE>8</span><span class=cF0>
|
|
<a name="l858"></a>
|
|
<a name="l859"></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, </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="l860"></a>{</span><span class=cF2>//Clip x1,y1 x2,y2 with left,top,right,bottom.</span><span class=cF0>
|
|
<a name="l861"></a> </span><span class=cF9>I64</span><span class=cF0> x, y, x1 = *_x1, y1 = *_y1, x2 = *_x2, y2 = *_y2, cc, cc1, cc2;
|
|
<a name="l862"></a>
|
|
<a name="l863"></a> </span><span class=cF1>if</span><span class=cF0> (y1 > bottom)
|
|
<a name="l864"></a> cc1 = </span><span class=cF3>CC_BOTTOM</span><span class=cF0>;
|
|
<a name="l865"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (y1 < top)
|
|
<a name="l866"></a> cc1 = </span><span class=cF3>CC_TOP</span><span class=cF0>;
|
|
<a name="l867"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l868"></a> cc1 = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l869"></a> </span><span class=cF1>if</span><span class=cF0> (x1 > right)
|
|
<a name="l870"></a> cc1 |= </span><span class=cF3>CC_RIGHT</span><span class=cF0>;
|
|
<a name="l871"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x1 < left)
|
|
<a name="l872"></a> cc1 |= </span><span class=cF3>CC_LEFT</span><span class=cF0>;
|
|
<a name="l873"></a>
|
|
<a name="l874"></a> </span><span class=cF1>if</span><span class=cF0> (y2 > bottom)
|
|
<a name="l875"></a> cc2 = </span><span class=cF3>CC_BOTTOM</span><span class=cF0>;
|
|
<a name="l876"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (y2 < top)
|
|
<a name="l877"></a> cc2 = </span><span class=cF3>CC_TOP</span><span class=cF0>;
|
|
<a name="l878"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l879"></a> cc2 = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l880"></a> </span><span class=cF1>if</span><span class=cF0> (x2 > right)
|
|
<a name="l881"></a> cc2 |= </span><span class=cF3>CC_RIGHT</span><span class=cF0>;
|
|
<a name="l882"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x2 < left)
|
|
<a name="l883"></a> cc2 |= </span><span class=cF3>CC_LEFT</span><span class=cF0>;
|
|
<a name="l884"></a>
|
|
<a name="l885"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l886"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l887"></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="l888"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l889"></a> </span><span class=cF1>if</span><span class=cF0> (cc1 & cc2)
|
|
<a name="l890"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l891"></a>
|
|
<a name="l892"></a> </span><span class=cF1>if</span><span class=cF0> (cc1)
|
|
<a name="l893"></a> cc = cc1;
|
|
<a name="l894"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l895"></a> cc = cc2;
|
|
<a name="l896"></a>
|
|
<a name="l897"></a> </span><span class=cF1>if</span><span class=cF0> (cc & </span><span class=cF3>CC_BOTTOM</span><span class=cF0>)
|
|
<a name="l898"></a> {
|
|
<a name="l899"></a> x = x1 + (x2 - x1) * (bottom - y1) / (y2 - y1);
|
|
<a name="l900"></a> y = bottom;
|
|
<a name="l901"></a> }
|
|
<a name="l902"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (cc & </span><span class=cF3>CC_TOP</span><span class=cF0>)
|
|
<a name="l903"></a> {
|
|
<a name="l904"></a> x = x1 + (x2 - x1) * (top - y1) / (y2 - y1);
|
|
<a name="l905"></a> y = top;
|
|
<a name="l906"></a> }
|
|
<a name="l907"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (cc & </span><span class=cF3>CC_RIGHT</span><span class=cF0>)
|
|
<a name="l908"></a> {
|
|
<a name="l909"></a> y = y1 + (y2 - y1) * (right - x1) / (x2 - x1);
|
|
<a name="l910"></a> x = right;
|
|
<a name="l911"></a> }
|
|
<a name="l912"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l913"></a> {
|
|
<a name="l914"></a> y = y1 + (y2 - y1) * (left - x1) / (x2 - x1);
|
|
<a name="l915"></a> x = left;
|
|
<a name="l916"></a> }
|
|
<a name="l917"></a>
|
|
<a name="l918"></a> </span><span class=cF1>if</span><span class=cF0> (cc == cc1)
|
|
<a name="l919"></a> {
|
|
<a name="l920"></a> *_x1 = x1 = x;
|
|
<a name="l921"></a> *_y1 = y1 = y;
|
|
<a name="l922"></a> </span><span class=cF1>if</span><span class=cF0> (y1 > bottom)
|
|
<a name="l923"></a> cc1 = </span><span class=cF3>CC_BOTTOM</span><span class=cF0>;
|
|
<a name="l924"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (y1 < top)
|
|
<a name="l925"></a> cc1 = </span><span class=cF3>CC_TOP</span><span class=cF0>;
|
|
<a name="l926"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l927"></a> cc1 = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l928"></a> </span><span class=cF1>if</span><span class=cF0> (x1 > right)
|
|
<a name="l929"></a> cc1 |= </span><span class=cF3>CC_RIGHT</span><span class=cF0>;
|
|
<a name="l930"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x1 < left)
|
|
<a name="l931"></a> cc1 |= </span><span class=cF3>CC_LEFT</span><span class=cF0>;
|
|
<a name="l932"></a> }
|
|
<a name="l933"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l934"></a> {
|
|
<a name="l935"></a> *_x2 = x2 = x;
|
|
<a name="l936"></a> *_y2 = y2 = y;
|
|
<a name="l937"></a> </span><span class=cF1>if</span><span class=cF0> (y2 > bottom)
|
|
<a name="l938"></a> cc2 = </span><span class=cF3>CC_BOTTOM</span><span class=cF0>;
|
|
<a name="l939"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (y2 < top)
|
|
<a name="l940"></a> cc2 = </span><span class=cF3>CC_TOP</span><span class=cF0>;
|
|
<a name="l941"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l942"></a> cc2 = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l943"></a> </span><span class=cF1>if</span><span class=cF0> (x2 > right)
|
|
<a name="l944"></a> cc2 |= </span><span class=cF3>CC_RIGHT</span><span class=cF0>;
|
|
<a name="l945"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (x2 < left)
|
|
<a name="l946"></a> cc2 |= </span><span class=cF3>CC_LEFT</span><span class=cF0>;
|
|
<a name="l947"></a> }
|
|
<a name="l948"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l949"></a>}
|
|
</span></pre></body>
|
|
</html>
|