Files
ViewDesignEngine/docs/api/interval_8h_source.html
T

213 lines
38 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ViewDesignEngine: include/vde/foundation/interval.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">ViewDesignEngine
&#160;<span id="projectnumber">3.1.0</span>
</div>
<div id="projectbrief">高性能 CAD 计算几何引擎</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','搜索');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('interval_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">interval.h</div> </div>
</div><!--header-->
<div class="contents">
<a href="interval_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="preprocessor">#include &lt;cmath&gt;</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="preprocessor">#include &lt;limits&gt;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="preprocessor">#include &lt;algorithm&gt;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160; </div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacevde_1_1foundation.html">vde::foundation</a> {</div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160; </div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html"> 20</a></span>&#160;<span class="keyword">class </span><a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> {</div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c"> 22</a></span>&#160; <span class="keywordtype">double</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>, <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>;</div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160; </div>
<div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a513bd7849e2e5521198340d19f820c8b"> 25</a></span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html#a513bd7849e2e5521198340d19f820c8b">Interval</a>() : <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>(0), <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>(0) {}</div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a66158db78aada3139dd0e9e07865872f"> 31</a></span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html#a66158db78aada3139dd0e9e07865872f">Interval</a>(<span class="keywordtype">double</span> v) : <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>(v), <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>(v) {}</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; </div>
<div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a5f84b35c3de5eb568941c7530dfdb933"> 41</a></span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5f84b35c3de5eb568941c7530dfdb933">Interval</a>(<span class="keywordtype">double</span> l, <span class="keywordtype">double</span> h) : <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>(std::min(l,h)), <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>(std::max(l,h)) {}</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; </div>
<div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a8619e852abc13e8b1b7f0e491d5583cc"> 47</a></span>&#160; [[nodiscard]] <span class="keywordtype">double</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a8619e852abc13e8b1b7f0e491d5583cc">mid</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a> + <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>) * 0.5; }</div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a47e0001ddecda2ec873331b722038e36"> 53</a></span>&#160; [[nodiscard]] <span class="keywordtype">double</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a47e0001ddecda2ec873331b722038e36">width</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a> - <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>; }</div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; </div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a1f1ee2ccbd77e563c348c049cb093083"> 60</a></span>&#160; [[nodiscard]] <span class="keywordtype">bool</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a1f1ee2ccbd77e563c348c049cb093083">contains</a>(<span class="keywordtype">double</span> v)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a> &lt;= v &amp;&amp; v &lt;= <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>; }</div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; </div>
<div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a62f6dda3323dc45de44338391945fa99"> 67</a></span>&#160; [[nodiscard]] <span class="keywordtype">bool</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a62f6dda3323dc45de44338391945fa99">is_exact</a>(<span class="keywordtype">double</span> eps = 1e-12)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a47e0001ddecda2ec873331b722038e36">width</a>() &lt; eps; }</div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; </div>
<div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a8f301412656c4c858d254b8f4452fa66"> 74</a></span>&#160; [[nodiscard]] <span class="keywordtype">bool</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a8f301412656c4c858d254b8f4452fa66">overlaps</a>(<span class="keyword">const</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a>&amp; o)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <span class="keywordflow">return</span> !(<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a> &lt; o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a> || o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a> &lt; <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>);</div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; }</div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; </div>
<div class="line"><a name="l00096"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#abf6c26f19ac4454879cdc7191e7e0b8b"> 96</a></span>&#160; [[nodiscard]] <span class="keywordtype">int</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html#abf6c26f19ac4454879cdc7191e7e0b8b">cmp</a>(<span class="keyword">const</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a>&amp; o)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a> &lt; o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>) <span class="keywordflow">return</span> -1; <span class="comment">// 确定 this &lt; o</span></div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a> &gt; o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>) <span class="keywordflow">return</span> 1; <span class="comment">// 确定 this &gt; o</span></div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; <span class="keywordflow">return</span> 0; <span class="comment">// 不确定(区间重叠)</span></div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; }</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; </div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; <span class="comment">// ── 算术运算 ──</span></div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; </div>
<div class="line"><a name="l00108"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a2b74a1061b46dc8d8c3c02fe7aa02e71"> 108</a></span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a2b74a1061b46dc8d8c3c02fe7aa02e71">operator+</a>(<span class="keyword">const</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a>&amp; o)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; <span class="keywordflow">return</span> {<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a> + o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>, <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a> + o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>};</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; }</div>
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160; </div>
<div class="line"><a name="l00116"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#ac2301940976c8126b99a825c061b5157"> 116</a></span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="classvde_1_1foundation_1_1Interval.html#ac2301940976c8126b99a825c061b5157">operator-</a>(<span class="keyword">const</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a>&amp; o)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160; <span class="keywordflow">return</span> {<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a> - o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>, <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a> - o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>};</div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; }</div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; </div>
<div class="line"><a name="l00127"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a94a315382cbe430157354b1bb0dbe3ec"> 127</a></span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a94a315382cbe430157354b1bb0dbe3ec">operator*</a>(<span class="keyword">const</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a>&amp; o)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>&#160; <span class="keywordtype">double</span> a = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>*o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>, b = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>*o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>, c = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>*o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>, d = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>*o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>;</div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>&#160; <span class="keywordflow">return</span> {std::min({a,b,c,d}), std::max({a,b,c,d})};</div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; }</div>
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>&#160; </div>
<div class="line"><a name="l00139"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a992ee44fc66758e9e75817373ea38c79"> 139</a></span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a992ee44fc66758e9e75817373ea38c79">operator/</a>(<span class="keyword">const</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a>&amp; o)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; <span class="keywordflow">if</span> (o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a> &lt;= 0 &amp;&amp; o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a> &gt;= 0) <span class="keywordflow">return</span> {-std::numeric_limits&lt;double&gt;::max(),</div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160; std::numeric_limits&lt;double&gt;::max()};</div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; <span class="keywordtype">double</span> a = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>/o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>, b = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>/o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>, c = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>/o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>, d = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>/o.<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>;</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160; <span class="keywordflow">return</span> {std::min({a,b,c,d}), std::max({a,b,c,d})};</div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; }</div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160; </div>
<div class="line"><a name="l00147"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#aa6bc5f91fe0b6c0137b72ef1108ee211"> 147</a></span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="classvde_1_1foundation_1_1Interval.html#aa6bc5f91fe0b6c0137b72ef1108ee211">operator-</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> {-<a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>, -<a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>}; }</div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; </div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160; <span class="comment">// ── 数学函数(保守区间)──</span></div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160; </div>
<div class="line"><a name="l00158"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#ac7b1ecc127128caeedac48534b79621b"> 158</a></span>&#160; [[nodiscard]] <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="classvde_1_1foundation_1_1Interval.html#ac7b1ecc127128caeedac48534b79621b">sqrt</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>&#160; <span class="keywordflow">return</span> {std::sqrt(std::max(0.0, <a class="code" href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">lo</a>)), std::sqrt(std::max(0.0, <a class="code" href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">hi</a>))};</div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160; }</div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160; </div>
<div class="line"><a name="l00169"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a66083ca9d23a0aa7deb6635d83377579"> 169</a></span>&#160; <span class="keyword">static</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a66083ca9d23a0aa7deb6635d83377579">from_double</a>(<span class="keywordtype">double</span> v, <span class="keywordtype">double</span> error = 0) {</div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; <span class="keywordflow">return</span> {v - error, v + error};</div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; }</div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; </div>
<div class="line"><a name="l00181"></a><span class="lineno"><a class="line" href="classvde_1_1foundation_1_1Interval.html#a98405097d818464d2ec44d9a12d4afff"> 181</a></span>&#160; <span class="keyword">static</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="classvde_1_1foundation_1_1Interval.html#a98405097d818464d2ec44d9a12d4afff">from_coord</a>(<span class="keywordtype">double</span> v) {</div>
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span>&#160; <span class="keywordtype">double</span> eps = std::abs(v) * 2.22e-16 + 1e-300;</div>
<div class="line"><a name="l00183"></a><span class="lineno"> 183</span>&#160; <span class="keywordflow">return</span> {v - eps, v + eps};</div>
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span>&#160; }</div>
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span>&#160;};</div>
<div class="line"><a name="l00186"></a><span class="lineno"> 186</span>&#160; </div>
<div class="line"><a name="l00200"></a><span class="lineno"><a class="line" href="group__foundation.html#ga4082e53f9e3afe884a6ea7b2005abfd1"> 200</a></span>&#160;<span class="keyword">inline</span> <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> <a class="code" href="group__foundation.html#ga4082e53f9e3afe884a6ea7b2005abfd1">orient_2d_interval</a>(<span class="keywordtype">double</span> ax, <span class="keywordtype">double</span> ay, <span class="keywordtype">double</span> bx, <span class="keywordtype">double</span> by, <span class="keywordtype">double</span> cx, <span class="keywordtype">double</span> cy) {</div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> acx = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a98405097d818464d2ec44d9a12d4afff">Interval::from_coord</a>(ax - cx);</div>
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> acy = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a98405097d818464d2ec44d9a12d4afff">Interval::from_coord</a>(ay - cy);</div>
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> bcx = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a98405097d818464d2ec44d9a12d4afff">Interval::from_coord</a>(bx - cx);</div>
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> bcy = <a class="code" href="classvde_1_1foundation_1_1Interval.html#a98405097d818464d2ec44d9a12d4afff">Interval::from_coord</a>(by - cy);</div>
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160; <span class="keywordflow">return</span> acx * bcy - acy * bcx;</div>
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160;}</div>
<div class="line"><a name="l00207"></a><span class="lineno"> 207</span>&#160; </div>
<div class="line"><a name="l00232"></a><span class="lineno"><a class="line" href="group__foundation.html#ga90b3b7375e3ad4e30cf60a286515d95b"> 232</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__foundation.html#ga90b3b7375e3ad4e30cf60a286515d95b">orient_2d_verified</a>(<span class="keywordtype">double</span> ax, <span class="keywordtype">double</span> ay, <span class="keywordtype">double</span> bx, <span class="keywordtype">double</span> by, <span class="keywordtype">double</span> cx, <span class="keywordtype">double</span> cy) {</div>
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160; <a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a> det = <a class="code" href="group__foundation.html#ga4082e53f9e3afe884a6ea7b2005abfd1">orient_2d_interval</a>(ax, ay, bx, by, cx, cy);</div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>&#160; <span class="keywordflow">return</span> det.<a class="code" href="classvde_1_1foundation_1_1Interval.html#abf6c26f19ac4454879cdc7191e7e0b8b">cmp</a>(<a class="code" href="classvde_1_1foundation_1_1Interval.html">Interval</a>(0.0));</div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160;}</div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160; </div>
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160;} <span class="comment">// namespace vde::foundation</span></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html">vde::foundation::Interval</a></div><div class="ttdoc">双精度区间算术类</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00020">interval.h:20</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a1f1ee2ccbd77e563c348c049cb093083"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a1f1ee2ccbd77e563c348c049cb093083">vde::foundation::Interval::contains</a></div><div class="ttdeci">bool contains(double v) const</div><div class="ttdoc">判断区间是否包含给定值</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00060">interval.h:60</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a2b74a1061b46dc8d8c3c02fe7aa02e71"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a2b74a1061b46dc8d8c3c02fe7aa02e71">vde::foundation::Interval::operator+</a></div><div class="ttdeci">Interval operator+(const Interval &amp;o) const</div><div class="ttdoc">区间加法</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00108">interval.h:108</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a47e0001ddecda2ec873331b722038e36"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a47e0001ddecda2ec873331b722038e36">vde::foundation::Interval::width</a></div><div class="ttdeci">double width() const</div><div class="ttdoc">区间宽度</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00053">interval.h:53</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a513bd7849e2e5521198340d19f820c8b"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a513bd7849e2e5521198340d19f820c8b">vde::foundation::Interval::Interval</a></div><div class="ttdeci">Interval()</div><div class="ttdoc">默认构造:空区间 [0, 0]</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00025">interval.h:25</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a5513b8d4cdc8c12dd44af8cdc1d8fbe7"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a5513b8d4cdc8c12dd44af8cdc1d8fbe7">vde::foundation::Interval::lo</a></div><div class="ttdeci">double lo</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00022">interval.h:22</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a5f84b35c3de5eb568941c7530dfdb933"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a5f84b35c3de5eb568941c7530dfdb933">vde::foundation::Interval::Interval</a></div><div class="ttdeci">Interval(double l, double h)</div><div class="ttdoc">从上下界构造区间</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00041">interval.h:41</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a62f6dda3323dc45de44338391945fa99"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a62f6dda3323dc45de44338391945fa99">vde::foundation::Interval::is_exact</a></div><div class="ttdeci">bool is_exact(double eps=1e-12) const</div><div class="ttdoc">判断区间是否足够窄(收敛)</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00067">interval.h:67</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a66083ca9d23a0aa7deb6635d83377579"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a66083ca9d23a0aa7deb6635d83377579">vde::foundation::Interval::from_double</a></div><div class="ttdeci">static Interval from_double(double v, double error=0)</div><div class="ttdoc">从双精度值创建区间(含舍入误差带)</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00169">interval.h:169</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a66158db78aada3139dd0e9e07865872f"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a66158db78aada3139dd0e9e07865872f">vde::foundation::Interval::Interval</a></div><div class="ttdeci">Interval(double v)</div><div class="ttdoc">从单值构造精确区间(退化为点)</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00031">interval.h:31</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a835e5615a8c670408c7f4ba438332b1c"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a835e5615a8c670408c7f4ba438332b1c">vde::foundation::Interval::hi</a></div><div class="ttdeci">double hi</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00022">interval.h:22</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a8619e852abc13e8b1b7f0e491d5583cc"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a8619e852abc13e8b1b7f0e491d5583cc">vde::foundation::Interval::mid</a></div><div class="ttdeci">double mid() const</div><div class="ttdoc">区间中点</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00047">interval.h:47</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a8f301412656c4c858d254b8f4452fa66"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a8f301412656c4c858d254b8f4452fa66">vde::foundation::Interval::overlaps</a></div><div class="ttdeci">bool overlaps(const Interval &amp;o) const</div><div class="ttdoc">判断两个区间是否有重叠</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00074">interval.h:74</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a94a315382cbe430157354b1bb0dbe3ec"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a94a315382cbe430157354b1bb0dbe3ec">vde::foundation::Interval::operator*</a></div><div class="ttdeci">Interval operator*(const Interval &amp;o) const</div><div class="ttdoc">区间乘法</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00127">interval.h:127</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a98405097d818464d2ec44d9a12d4afff"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a98405097d818464d2ec44d9a12d4afff">vde::foundation::Interval::from_coord</a></div><div class="ttdeci">static Interval from_coord(double v)</div><div class="ttdoc">从坐标值创建区间(含 ULP 误差带)</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00181">interval.h:181</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_a992ee44fc66758e9e75817373ea38c79"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#a992ee44fc66758e9e75817373ea38c79">vde::foundation::Interval::operator/</a></div><div class="ttdeci">Interval operator/(const Interval &amp;o) const</div><div class="ttdoc">区间除法</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00139">interval.h:139</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_aa6bc5f91fe0b6c0137b72ef1108ee211"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#aa6bc5f91fe0b6c0137b72ef1108ee211">vde::foundation::Interval::operator-</a></div><div class="ttdeci">Interval operator-() const</div><div class="ttdoc">取负</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00147">interval.h:147</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_abf6c26f19ac4454879cdc7191e7e0b8b"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#abf6c26f19ac4454879cdc7191e7e0b8b">vde::foundation::Interval::cmp</a></div><div class="ttdeci">int cmp(const Interval &amp;o) const</div><div class="ttdoc">确定性区间比较</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00096">interval.h:96</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_ac2301940976c8126b99a825c061b5157"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#ac2301940976c8126b99a825c061b5157">vde::foundation::Interval::operator-</a></div><div class="ttdeci">Interval operator-(const Interval &amp;o) const</div><div class="ttdoc">区间减法</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00116">interval.h:116</a></div></div>
<div class="ttc" id="aclassvde_1_1foundation_1_1Interval_html_ac7b1ecc127128caeedac48534b79621b"><div class="ttname"><a href="classvde_1_1foundation_1_1Interval.html#ac7b1ecc127128caeedac48534b79621b">vde::foundation::Interval::sqrt</a></div><div class="ttdeci">Interval sqrt() const</div><div class="ttdoc">区间平方根</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00158">interval.h:158</a></div></div>
<div class="ttc" id="agroup__foundation_html_ga4082e53f9e3afe884a6ea7b2005abfd1"><div class="ttname"><a href="group__foundation.html#ga4082e53f9e3afe884a6ea7b2005abfd1">vde::foundation::orient_2d_interval</a></div><div class="ttdeci">Interval orient_2d_interval(double ax, double ay, double bx, double by, double cx, double cy)</div><div class="ttdoc">二维定向行列式的区间验证</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00200">interval.h:200</a></div></div>
<div class="ttc" id="agroup__foundation_html_ga90b3b7375e3ad4e30cf60a286515d95b"><div class="ttname"><a href="group__foundation.html#ga90b3b7375e3ad4e30cf60a286515d95b">vde::foundation::orient_2d_verified</a></div><div class="ttdeci">int orient_2d_verified(double ax, double ay, double bx, double by, double cx, double cy)</div><div class="ttdoc">使用区间算术验证 orient_2d 结果</div><div class="ttdef"><b>Definition:</b> <a href="interval_8h_source.html#l00232">interval.h:232</a></div></div>
<div class="ttc" id="anamespacevde_1_1foundation_html"><div class="ttname"><a href="namespacevde_1_1foundation.html">vde::foundation</a></div><div class="ttdoc">自适应双精度谓词后端(默认)</div><div class="ttdef"><b>Definition:</b> <a href="error__codes_8h_source.html#l00004">error_codes.h:4</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_36dfe8171299c47a6036082559f11ede.html">vde</a></li><li class="navelem"><a class="el" href="dir_0c2101f4fe537748a6dd635dd73c637a.html">foundation</a></li><li class="navelem"><a class="el" href="interval_8h.html">interval.h</a></li>
<li class="footer">生成于 2026年 七月 24日 星期五 11:21:23 , 为 ViewDesignEngine使用 <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
</ul>
</div>
</body>
</html>