How to handle a double in CAD modeling
来源:互联网 发布:计算机二级vb题库 编辑:程序博客网 时间:2024/06/05 10:19
1. The way of Kbool.
http://boolean.klaasholwerda.nl/algdoc/basicstepsframe.html
Assuming the input data is supplied in doubles, the coordinates will be converted to 64bit integers.
This is done using two scale factors, DGRID and GRID.
DGRID defines the accuracy the user wants
an accuracy of two digits means DGRID should be set to DGRID = 0.01
Although in the boolean algorithm the accuracy is higher, the end result will be rounded to the DGRID.
GRID defines the number of digits the boolean algorithm will use to calculate extra intersection.
If for instance two segments intersect the intersection point does not have to be on the GRID.
If the GRID would be set to 1, there would be no integer number in between to define this intersection point.
With the GRID set to 100 there is place for those intersections, in this case the intersection point would be (50,50).
In fact the algorithm uses a kind of integer fixed point calculation for coordinates, the fractional part is always fixed (least significant 2 digits) .
For instance if the DGRID = 0.01 and GRID = 100 and the original polygon point is (1234.56,4567.89).
The following coordinate will be used inside the boolean algorithms (12345600,45678900).
So multiplied by 1/DGRID converts the doubles to integers.
GRID = 100 means multiply those integers with an extra factor to create space for the boolean algorithm to create intersections in between.
In the end all points will be converted back to double with an accuracy of DGRID.
This means all new intersection points will also be rounded to the DGRID in the end, if the user wants those intersection to be more accurate
than his input data, the DGRID should be set smaller than the accuracy of the input data.
2. Transform a double to the nearest int:
for example: 0.999 to 1 and -0.999 to -1
Two ways:
(1): floor(doubleer+0.5)
(2):
if (doubleer > 0)
{
return (int)(doubleer+0.5);
}
else
{
return (int)(doubleer-0.5);
}
- How to handle a double in CAD modeling
- How To Handle Row Selection in UITableView
- how to handle the c string and comments in flex
- WPF--How to handle WndProc messages in WPF?
- How to handle the session in HttpClient 4.1
- How to handle the space in column with awk?
- [Python]How to handle the exception in Python?
- How to handle exception in managed code and unmanaged code
- How to handle exception in managed code and unmanaged code
- How to send and handle a custom Windows message
- How to get a handle to a device driver returned by device manager?
- How to handle blocking clicks
- How to Succeed in A Professional Career
- How To: Implement A Server Plug-in
- How to create a user in PostgreSQL
- How to Rename a View in ClearCase
- How to execute a query in varchar2 ?
- How to Rename a View in ClearCase
- FreeTextBox 光标处插入html内容
- 最令我。。。。的一首诗
- SmartGwt: attempt to use DataSource of type iscServer without SmartClient Server option.
- 如果截取处未关闭标签,向下找关闭标签,再截取
- Oracle Concept 的一些笔记 -- Data Dictionary
- How to handle a double in CAD modeling
- linux下获取用户基本信息
- 嵌入式FTP服务器的移植与配置:VSFTPD-2.0.6移植
- 关于Use MFC in a Shared DLL和Use MFC in a Static Library 转换遇到的问题
- fd
- 网页优化的若干准则
- 大家好
- 什么是MVC(三层架构)
- CR和LF,回车换行符心得