⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 group__fixed__math__fns.htm

📁 MINIGUI1.6开发API
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>MiniGUI V1.6.10 API Reference: Fixed point math functions</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.2 --><div class="qindex"><a class="qindex" href="index.htm">Main&nbsp;Page</a> | <a class="qindex" href="modules.htm">Modules</a> | <a class="qindex" href="classes.htm">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.htm">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.htm">Directories</a> | <a class="qindex" href="files.htm">File&nbsp;List</a> | <a class="qindex" href="functions.htm">Data&nbsp;Fields</a> | <a class="qindex" href="globals.htm">Globals</a> | <a class="qindex" href="pages.htm">Related&nbsp;Pages</a></div><h1>Fixed point math functions<br><small>[<a class="el" href="group__global__fns.htm">Global/general functions</a>]</small></h1><h2>Functions</h2><ul><li>MG_EXPORT <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga3">fixsqrt</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Returns the non-negative square root of a fixed point value.  <a href="#ga3"></a><br></dl><li>MG_EXPORT <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga4">fixhypot</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x, <a class="el" href="group__gdi__types.htm#ga10">fixed</a> y)<dl class="el"><dd class="mdescRight">Returns the Euclidean distance from the origin.  <a href="#ga4"></a><br></dl><li>MG_EXPORT <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga5">fixatan</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Calculates the arc tangent of a fixed point value.  <a href="#ga5"></a><br></dl><li>MG_EXPORT <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga6">fixatan2</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> y, <a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Calculates the arc tangent of two fixed point variables.  <a href="#ga6"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga7">ftofix</a> (double x)<dl class="el"><dd class="mdescRight">Converts a float point value to a fixed point value.  <a href="#ga7"></a><br></dl><li>static double <a class="el" href="group__fixed__math__fns.htm#ga8">fixtof</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Converts a fixed point value to a float point value.  <a href="#ga8"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga9">fixadd</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x, <a class="el" href="group__gdi__types.htm#ga10">fixed</a> y)<dl class="el"><dd class="mdescRight">Returns the sum of two fixed point values.  <a href="#ga9"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga10">fixsub</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x, <a class="el" href="group__gdi__types.htm#ga10">fixed</a> y)<dl class="el"><dd class="mdescRight">Subtract a fixed point value from another.  <a href="#ga10"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga11">fixmul</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x, <a class="el" href="group__gdi__types.htm#ga10">fixed</a> y)<dl class="el"><dd class="mdescRight">Returns the product of two fixed point values.  <a href="#ga11"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga12">fixdiv</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x, <a class="el" href="group__gdi__types.htm#ga10">fixed</a> y)<dl class="el"><dd class="mdescRight">Returns the quotient of two fixed point values.  <a href="#ga12"></a><br></dl><li>static int <a class="el" href="group__fixed__math__fns.htm#ga13">fixceil</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Rounds a fixed point value to the nearest integer.  <a href="#ga13"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga14">itofix</a> (int x)<dl class="el"><dd class="mdescRight">Converts an integer to a fixed point value.  <a href="#ga14"></a><br></dl><li>static int <a class="el" href="group__fixed__math__fns.htm#ga15">fixtoi</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Converts an fixed point value to an integer.  <a href="#ga15"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga16">fixcos</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Returns the cosine of a fixed point.  <a href="#ga16"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga17">fixsin</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Returns the sine of a fixed point.  <a href="#ga17"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga18">fixtan</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Returns the tangent of a fixed point.  <a href="#ga18"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga19">fixacos</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Calculates and returns the arc cosine of a fixed point.  <a href="#ga19"></a><br></dl><li>static <a class="el" href="group__gdi__types.htm#ga10">fixed</a> <a class="el" href="group__fixed__math__fns.htm#ga20">fixasin</a> (<a class="el" href="group__gdi__types.htm#ga10">fixed</a> x)<dl class="el"><dd class="mdescRight">Calculates and returns the arc sine of a fixed point.  <a href="#ga20"></a><br></dl></ul><hr><a name="_details"></a><h2>Detailed Description</h2>You know that the float point mathematics routines are very expensive. If you do not want precision mathematics result, you can use fixed point. MiniGUI uses a double word (32-bit) integer to represent a fixed point ranged from -32767.0 to 32767.0, and defines some fixed point mathematics routines for your application. Some GDI functions need fixed point math routines, like <em>Arc</em>.<p>Example 1:<p><div class="fragment"><pre class="fragment">    <span class="comment">/* Draw an arc from 0 radians to 1 radians */</span>    Arc (hdc, 100, 100, 100, 0, <a class="code" href="group__fixed__math__fns.htm#ga14">itofix</a> (1));    <span class="comment">/* Draw an arc from 0.5 radians to 1.5 radians */</span>    <a class="code" href="group__gdi__types.htm#ga10">fixed</a> radian1 = <a class="code" href="group__fixed__math__fns.htm#ga14">itofix</a> (1);    <a class="code" href="group__gdi__types.htm#ga10">fixed</a> radian2 = <a class="code" href="group__fixed__math__fns.htm#ga14">itofix</a> (2);    <a class="code" href="group__gdi__types.htm#ga10">fixed</a> radian05 = fdiv (radian1, radian2);    <a class="code" href="group__gdi__types.htm#ga10">fixed</a> radian15 = fdiv (fadd (radian1, randian2), radian2);    Arc (hdc, 100, 100, 100, radian05, radian15);</pre></div><p>Example 2:<p><div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> draw_arc (<a class="code" href="group__handles.htm#ga2">HDC</a> hdc, <a class="code" href="struct__POINT.htm">POINT</a>* pts){            <span class="keywordtype">int</span> sx = pts [0].<a class="code" href="struct__POINT.htm#o0">x</a>, sy = pts [0].<a class="code" href="struct__POINT.htm#o1">y</a>;            <span class="keywordtype">int</span> dx = pts [1].<a class="code" href="struct__POINT.htm#o0">x</a> - sx, dy = pts [1].<a class="code" href="struct__POINT.htm#o1">y</a> - sy;            <span class="keywordtype">int</span> r = sqrt (dx * dx * 1.0 + dy * dy * 1.0);            <span class="keywordtype">double</span> cos_d = dx * 1.0 / r;            <a class="code" href="group__gdi__types.htm#ga10">fixed</a> cos_f = <a class="code" href="group__fixed__math__fns.htm#ga7">ftofix</a> (cos_d);            <a class="code" href="group__gdi__types.htm#ga10">fixed</a> ang1 = facos (cos_f);            <span class="keywordtype">int</span> r2;            <a class="code" href="group__gdi__types.htm#ga10">fixed</a> ang2;            <span class="keywordflow">if</span> (dy &gt; 0) {                ang1 = fsub (0, ang1);            }            dx = pts [2].<a class="code" href="struct__POINT.htm#o0">x</a> - sx;            dy = pts [2].<a class="code" href="struct__POINT.htm#o1">y</a> - sy;            r2 = sqrt (dx * dx * 1.0 + dy * dy * 1.0);            cos_d = dx * 1.0 / r2;            cos_f = <a class="code" href="group__fixed__math__fns.htm#ga7">ftofix</a> (cos_d);            ang2 = facos (cos_f);            <span class="keywordflow">if</span> (dy &gt; 0) {                ang2 = fsub (0, ang2);            }            Arc (hdc, sx, sy, r, ang1, ang2);}</pre></div> <hr><h2>Function Documentation</h2><a class="anchor" name="ga19" doxytag="fixedmath.h::fixacos"></a><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a> fixacos           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a>&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>x</em>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap><code> [inline, static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Calculates and returns the arc cosine of a fixed point. <p>This function calculates the arc cosine of the fixed point <em>x</em>; that is the value whose cosine is <em>x</em>. If <em>x</em> falls outside the range -1 to 1, this function fails and <em>errno</em> is set to EDOM.<p><dl compact><dt><b>Returns:</b></dt><dd>Returns the arc cosine in radians and the value is mathematically defined to be between 0 and PI (inclusive).</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__fixed__math__fns.htm#ga16">fixcos</a> </dd></dl><p>Definition at line <a class="el" href="fixedmath_8h-source.htm#l00399">399</a> of file <a class="el" href="fixedmath_8h-source.htm">fixedmath.h</a>.    </td>  </tr></table><a class="anchor" name="ga9" doxytag="fixedmath.h::fixadd"></a><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a> fixadd           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a>&nbsp;</td>          <td class="mdname" nowrap> <em>x</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap><a class="el" href="group__gdi__types.htm#ga10">fixed</a>&nbsp;</td>          <td class="mdname" nowrap> <em>y</em></td>        </tr>        <tr>          <td class="md"></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"><code> [inline, static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Returns the sum of two fixed point values. <p>This function adds two fixed point values <em>x</em> and <em>y</em>, and returns the sum.<p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>x</em>&nbsp;</td><td>x,y: Two addends. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>y</em>&nbsp;</td><td>x,y: Two addends. </td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd>The sum. If the result runs out of range of fixed point, this function sets <em>errno</em> to <em>ERANGE</em>.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__fixed__math__fns.htm#ga10">fixsub</a> </dd></dl><p>Definition at line <a class="el" href="fixedmath_8h-source.htm#l00194">194</a> of file <a class="el" href="fixedmath_8h-source.htm">fixedmath.h</a>.    </td>  </tr></table><a class="anchor" name="ga20" doxytag="fixedmath.h::fixasin"></a><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a> fixasin           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a>&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>x</em>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap><code> [inline, static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Calculates and returns the arc sine of a fixed point. <p>This function calculates the arc sine of the fixed point <em>x</em>; that is the value whose sine is <em>x</em>. If <em>x</em> falls outside the range -1 to 1, this function fails and <em>errno</em> is set to EDOM.<p><dl compact><dt><b>Returns:</b></dt><dd>Returns the arc sine in radians and the value is mathematically defined to be between -PI/2 and PI/2 (inclusive).</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__fixed__math__fns.htm#ga17">fixsin</a> </dd></dl><p>Definition at line <a class="el" href="fixedmath_8h-source.htm#l00422">422</a> of file <a class="el" href="fixedmath_8h-source.htm">fixedmath.h</a>.    </td>  </tr></table><a class="anchor" name="ga5" doxytag="fixedmath.h::fixatan"></a><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a> fixatan           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a>&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>x</em>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Calculates the arc tangent of a fixed point value. <p>This function calculates the arc tangent of <em>x</em>; that is the value whose tangent is <em>x</em>.<p><dl compact><dt><b>Returns:</b></dt><dd>Returns the arc tangent in radians and the value is mathematically defined to be between -PI/2 and PI/2 (inclusive).</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__fixed__math__fns.htm#ga6">fixatan2</a> </dd></dl>    </td>  </tr></table><a class="anchor" name="ga6" doxytag="fixedmath.h::fixatan2"></a><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a> fixatan2           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdi__types.htm#ga10">fixed</a>&nbsp;</td>          <td class="mdname" nowrap> <em>y</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap><a class="el" href="group__gdi__types.htm#ga10">fixed</a>&nbsp;</td>          <td class="mdname" nowrap> <em>x</em></td>        </tr>        <tr>          <td class="md"></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -