netgen-mesher 6.2.2506.post35.dev0__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. netgen/NgOCC.py +7 -0
  2. netgen/__init__.py +114 -0
  3. netgen/__init__.pyi +22 -0
  4. netgen/__main__.py +53 -0
  5. netgen/cmake/NetgenConfig.cmake +79 -0
  6. netgen/cmake/netgen-targets-release.cmake +69 -0
  7. netgen/cmake/netgen-targets.cmake +146 -0
  8. netgen/config/__init__.py +1 -0
  9. netgen/config/__init__.pyi +52 -0
  10. netgen/config/__main__.py +4 -0
  11. netgen/config/config.py +68 -0
  12. netgen/config/config.pyi +54 -0
  13. netgen/csg.py +25 -0
  14. netgen/geom2d.py +178 -0
  15. netgen/gui.py +82 -0
  16. netgen/include/core/archive.hpp +1256 -0
  17. netgen/include/core/array.hpp +1760 -0
  18. netgen/include/core/autodiff.hpp +1131 -0
  19. netgen/include/core/autodiffdiff.hpp +733 -0
  20. netgen/include/core/bitarray.hpp +240 -0
  21. netgen/include/core/concurrentqueue.h +3619 -0
  22. netgen/include/core/exception.hpp +145 -0
  23. netgen/include/core/flags.hpp +199 -0
  24. netgen/include/core/hashtable.hpp +1281 -0
  25. netgen/include/core/localheap.hpp +318 -0
  26. netgen/include/core/logging.hpp +117 -0
  27. netgen/include/core/memtracer.hpp +221 -0
  28. netgen/include/core/mpi4py_pycapi.h +245 -0
  29. netgen/include/core/mpi_wrapper.hpp +643 -0
  30. netgen/include/core/ng_mpi.hpp +94 -0
  31. netgen/include/core/ng_mpi_generated_declarations.hpp +155 -0
  32. netgen/include/core/ng_mpi_native.hpp +25 -0
  33. netgen/include/core/ngcore.hpp +32 -0
  34. netgen/include/core/ngcore_api.hpp +152 -0
  35. netgen/include/core/ngstream.hpp +115 -0
  36. netgen/include/core/paje_trace.hpp +279 -0
  37. netgen/include/core/profiler.hpp +382 -0
  38. netgen/include/core/python_ngcore.hpp +457 -0
  39. netgen/include/core/ranges.hpp +109 -0
  40. netgen/include/core/register_archive.hpp +100 -0
  41. netgen/include/core/signal.hpp +82 -0
  42. netgen/include/core/simd.hpp +160 -0
  43. netgen/include/core/simd_arm64.hpp +407 -0
  44. netgen/include/core/simd_avx.hpp +394 -0
  45. netgen/include/core/simd_avx512.hpp +285 -0
  46. netgen/include/core/simd_generic.hpp +1053 -0
  47. netgen/include/core/simd_math.hpp +178 -0
  48. netgen/include/core/simd_sse.hpp +289 -0
  49. netgen/include/core/statushandler.hpp +37 -0
  50. netgen/include/core/symboltable.hpp +153 -0
  51. netgen/include/core/table.hpp +810 -0
  52. netgen/include/core/taskmanager.hpp +1161 -0
  53. netgen/include/core/type_traits.hpp +65 -0
  54. netgen/include/core/utils.hpp +385 -0
  55. netgen/include/core/version.hpp +102 -0
  56. netgen/include/core/xbool.hpp +47 -0
  57. netgen/include/csg/algprim.hpp +563 -0
  58. netgen/include/csg/brick.hpp +150 -0
  59. netgen/include/csg/csg.hpp +43 -0
  60. netgen/include/csg/csgeom.hpp +389 -0
  61. netgen/include/csg/csgparser.hpp +101 -0
  62. netgen/include/csg/curve2d.hpp +67 -0
  63. netgen/include/csg/edgeflw.hpp +112 -0
  64. netgen/include/csg/explicitcurve2d.hpp +113 -0
  65. netgen/include/csg/extrusion.hpp +185 -0
  66. netgen/include/csg/gencyl.hpp +70 -0
  67. netgen/include/csg/geoml.hpp +16 -0
  68. netgen/include/csg/identify.hpp +213 -0
  69. netgen/include/csg/manifold.hpp +29 -0
  70. netgen/include/csg/meshsurf.hpp +46 -0
  71. netgen/include/csg/polyhedra.hpp +121 -0
  72. netgen/include/csg/revolution.hpp +180 -0
  73. netgen/include/csg/singularref.hpp +84 -0
  74. netgen/include/csg/solid.hpp +295 -0
  75. netgen/include/csg/specpoin.hpp +194 -0
  76. netgen/include/csg/spline3d.hpp +99 -0
  77. netgen/include/csg/splinesurface.hpp +85 -0
  78. netgen/include/csg/surface.hpp +394 -0
  79. netgen/include/csg/triapprox.hpp +63 -0
  80. netgen/include/csg/vscsg.hpp +34 -0
  81. netgen/include/general/autodiff.hpp +356 -0
  82. netgen/include/general/autoptr.hpp +39 -0
  83. netgen/include/general/gzstream.h +121 -0
  84. netgen/include/general/hashtabl.hpp +1692 -0
  85. netgen/include/general/myadt.hpp +48 -0
  86. netgen/include/general/mystring.hpp +226 -0
  87. netgen/include/general/netgenout.hpp +205 -0
  88. netgen/include/general/ngarray.hpp +797 -0
  89. netgen/include/general/ngbitarray.hpp +149 -0
  90. netgen/include/general/ngpython.hpp +74 -0
  91. netgen/include/general/optmem.hpp +44 -0
  92. netgen/include/general/parthreads.hpp +138 -0
  93. netgen/include/general/seti.hpp +50 -0
  94. netgen/include/general/sort.hpp +47 -0
  95. netgen/include/general/spbita2d.hpp +59 -0
  96. netgen/include/general/stack.hpp +114 -0
  97. netgen/include/general/table.hpp +280 -0
  98. netgen/include/general/template.hpp +509 -0
  99. netgen/include/geom2d/csg2d.hpp +750 -0
  100. netgen/include/geom2d/geometry2d.hpp +280 -0
  101. netgen/include/geom2d/spline2d.hpp +234 -0
  102. netgen/include/geom2d/vsgeom2d.hpp +28 -0
  103. netgen/include/gprim/adtree.hpp +1392 -0
  104. netgen/include/gprim/geom2d.hpp +858 -0
  105. netgen/include/gprim/geom3d.hpp +749 -0
  106. netgen/include/gprim/geomfuncs.hpp +212 -0
  107. netgen/include/gprim/geomobjects.hpp +544 -0
  108. netgen/include/gprim/geomops.hpp +404 -0
  109. netgen/include/gprim/geomtest3d.hpp +101 -0
  110. netgen/include/gprim/gprim.hpp +33 -0
  111. netgen/include/gprim/spline.hpp +778 -0
  112. netgen/include/gprim/splinegeometry.hpp +73 -0
  113. netgen/include/gprim/transform3d.hpp +216 -0
  114. netgen/include/include/acisgeom.hpp +3 -0
  115. netgen/include/include/csg.hpp +1 -0
  116. netgen/include/include/geometry2d.hpp +1 -0
  117. netgen/include/include/gprim.hpp +1 -0
  118. netgen/include/include/incopengl.hpp +62 -0
  119. netgen/include/include/inctcl.hpp +13 -0
  120. netgen/include/include/incvis.hpp +6 -0
  121. netgen/include/include/linalg.hpp +1 -0
  122. netgen/include/include/meshing.hpp +1 -0
  123. netgen/include/include/myadt.hpp +1 -0
  124. netgen/include/include/mydefs.hpp +70 -0
  125. netgen/include/include/mystdlib.h +59 -0
  126. netgen/include/include/netgen_config.hpp +27 -0
  127. netgen/include/include/netgen_version.hpp +9 -0
  128. netgen/include/include/nginterface_v2_impl.hpp +395 -0
  129. netgen/include/include/ngsimd.hpp +1 -0
  130. netgen/include/include/occgeom.hpp +1 -0
  131. netgen/include/include/opti.hpp +1 -0
  132. netgen/include/include/parallel.hpp +1 -0
  133. netgen/include/include/stlgeom.hpp +1 -0
  134. netgen/include/include/visual.hpp +1 -0
  135. netgen/include/interface/rw_medit.hpp +11 -0
  136. netgen/include/interface/writeuser.hpp +80 -0
  137. netgen/include/linalg/densemat.hpp +414 -0
  138. netgen/include/linalg/linalg.hpp +29 -0
  139. netgen/include/linalg/opti.hpp +142 -0
  140. netgen/include/linalg/polynomial.hpp +47 -0
  141. netgen/include/linalg/vector.hpp +217 -0
  142. netgen/include/meshing/adfront2.hpp +274 -0
  143. netgen/include/meshing/adfront3.hpp +332 -0
  144. netgen/include/meshing/basegeom.hpp +370 -0
  145. netgen/include/meshing/bcfunctions.hpp +53 -0
  146. netgen/include/meshing/bisect.hpp +72 -0
  147. netgen/include/meshing/boundarylayer.hpp +113 -0
  148. netgen/include/meshing/classifyhpel.hpp +1984 -0
  149. netgen/include/meshing/clusters.hpp +46 -0
  150. netgen/include/meshing/curvedelems.hpp +274 -0
  151. netgen/include/meshing/delaunay2d.hpp +73 -0
  152. netgen/include/meshing/fieldlines.hpp +103 -0
  153. netgen/include/meshing/findip.hpp +198 -0
  154. netgen/include/meshing/findip2.hpp +103 -0
  155. netgen/include/meshing/geomsearch.hpp +69 -0
  156. netgen/include/meshing/global.hpp +54 -0
  157. netgen/include/meshing/hpref_hex.hpp +330 -0
  158. netgen/include/meshing/hpref_prism.hpp +3405 -0
  159. netgen/include/meshing/hpref_pyramid.hpp +154 -0
  160. netgen/include/meshing/hpref_quad.hpp +2082 -0
  161. netgen/include/meshing/hpref_segm.hpp +122 -0
  162. netgen/include/meshing/hpref_tet.hpp +4230 -0
  163. netgen/include/meshing/hpref_trig.hpp +848 -0
  164. netgen/include/meshing/hprefinement.hpp +366 -0
  165. netgen/include/meshing/improve2.hpp +178 -0
  166. netgen/include/meshing/improve3.hpp +151 -0
  167. netgen/include/meshing/localh.hpp +223 -0
  168. netgen/include/meshing/meshclass.hpp +1076 -0
  169. netgen/include/meshing/meshfunc.hpp +47 -0
  170. netgen/include/meshing/meshing.hpp +63 -0
  171. netgen/include/meshing/meshing2.hpp +163 -0
  172. netgen/include/meshing/meshing3.hpp +123 -0
  173. netgen/include/meshing/meshtool.hpp +90 -0
  174. netgen/include/meshing/meshtype.hpp +1930 -0
  175. netgen/include/meshing/msghandler.hpp +62 -0
  176. netgen/include/meshing/paralleltop.hpp +172 -0
  177. netgen/include/meshing/python_mesh.hpp +206 -0
  178. netgen/include/meshing/ruler2.hpp +172 -0
  179. netgen/include/meshing/ruler3.hpp +211 -0
  180. netgen/include/meshing/soldata.hpp +141 -0
  181. netgen/include/meshing/specials.hpp +17 -0
  182. netgen/include/meshing/surfacegeom.hpp +73 -0
  183. netgen/include/meshing/topology.hpp +1003 -0
  184. netgen/include/meshing/validate.hpp +21 -0
  185. netgen/include/meshing/visual_interface.hpp +71 -0
  186. netgen/include/mydefs.hpp +70 -0
  187. netgen/include/nginterface.h +474 -0
  188. netgen/include/nginterface_v2.hpp +406 -0
  189. netgen/include/nglib.h +697 -0
  190. netgen/include/nglib_occ.h +50 -0
  191. netgen/include/occ/occ_edge.hpp +47 -0
  192. netgen/include/occ/occ_face.hpp +52 -0
  193. netgen/include/occ/occ_solid.hpp +23 -0
  194. netgen/include/occ/occ_utils.hpp +376 -0
  195. netgen/include/occ/occ_vertex.hpp +30 -0
  196. netgen/include/occ/occgeom.hpp +659 -0
  197. netgen/include/occ/occmeshsurf.hpp +168 -0
  198. netgen/include/occ/vsocc.hpp +33 -0
  199. netgen/include/pybind11/LICENSE +29 -0
  200. netgen/include/pybind11/attr.h +722 -0
  201. netgen/include/pybind11/buffer_info.h +208 -0
  202. netgen/include/pybind11/cast.h +2361 -0
  203. netgen/include/pybind11/chrono.h +228 -0
  204. netgen/include/pybind11/common.h +2 -0
  205. netgen/include/pybind11/complex.h +74 -0
  206. netgen/include/pybind11/conduit/README.txt +15 -0
  207. netgen/include/pybind11/conduit/pybind11_conduit_v1.h +116 -0
  208. netgen/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
  209. netgen/include/pybind11/conduit/wrap_include_python_h.h +72 -0
  210. netgen/include/pybind11/critical_section.h +56 -0
  211. netgen/include/pybind11/detail/class.h +823 -0
  212. netgen/include/pybind11/detail/common.h +1348 -0
  213. netgen/include/pybind11/detail/cpp_conduit.h +75 -0
  214. netgen/include/pybind11/detail/descr.h +226 -0
  215. netgen/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
  216. netgen/include/pybind11/detail/exception_translation.h +71 -0
  217. netgen/include/pybind11/detail/function_record_pyobject.h +191 -0
  218. netgen/include/pybind11/detail/init.h +538 -0
  219. netgen/include/pybind11/detail/internals.h +799 -0
  220. netgen/include/pybind11/detail/native_enum_data.h +209 -0
  221. netgen/include/pybind11/detail/pybind11_namespace_macros.h +82 -0
  222. netgen/include/pybind11/detail/struct_smart_holder.h +378 -0
  223. netgen/include/pybind11/detail/type_caster_base.h +1591 -0
  224. netgen/include/pybind11/detail/typeid.h +65 -0
  225. netgen/include/pybind11/detail/using_smart_holder.h +22 -0
  226. netgen/include/pybind11/detail/value_and_holder.h +90 -0
  227. netgen/include/pybind11/eigen/common.h +9 -0
  228. netgen/include/pybind11/eigen/matrix.h +723 -0
  229. netgen/include/pybind11/eigen/tensor.h +521 -0
  230. netgen/include/pybind11/eigen.h +12 -0
  231. netgen/include/pybind11/embed.h +320 -0
  232. netgen/include/pybind11/eval.h +161 -0
  233. netgen/include/pybind11/functional.h +147 -0
  234. netgen/include/pybind11/gil.h +199 -0
  235. netgen/include/pybind11/gil_safe_call_once.h +102 -0
  236. netgen/include/pybind11/gil_simple.h +37 -0
  237. netgen/include/pybind11/iostream.h +265 -0
  238. netgen/include/pybind11/native_enum.h +67 -0
  239. netgen/include/pybind11/numpy.h +2312 -0
  240. netgen/include/pybind11/operators.h +202 -0
  241. netgen/include/pybind11/options.h +92 -0
  242. netgen/include/pybind11/pybind11.h +3645 -0
  243. netgen/include/pybind11/pytypes.h +2680 -0
  244. netgen/include/pybind11/stl/filesystem.h +114 -0
  245. netgen/include/pybind11/stl.h +666 -0
  246. netgen/include/pybind11/stl_bind.h +858 -0
  247. netgen/include/pybind11/subinterpreter.h +299 -0
  248. netgen/include/pybind11/trampoline_self_life_support.h +65 -0
  249. netgen/include/pybind11/type_caster_pyobject_ptr.h +61 -0
  250. netgen/include/pybind11/typing.h +298 -0
  251. netgen/include/pybind11/warnings.h +75 -0
  252. netgen/include/stlgeom/meshstlsurface.hpp +67 -0
  253. netgen/include/stlgeom/stlgeom.hpp +491 -0
  254. netgen/include/stlgeom/stlline.hpp +193 -0
  255. netgen/include/stlgeom/stltool.hpp +331 -0
  256. netgen/include/stlgeom/stltopology.hpp +419 -0
  257. netgen/include/stlgeom/vsstl.hpp +58 -0
  258. netgen/include/visualization/meshdoc.hpp +42 -0
  259. netgen/include/visualization/mvdraw.hpp +325 -0
  260. netgen/include/visualization/vispar.hpp +128 -0
  261. netgen/include/visualization/visual.hpp +28 -0
  262. netgen/include/visualization/visual_api.hpp +10 -0
  263. netgen/include/visualization/vssolution.hpp +399 -0
  264. netgen/lib/libnggui.lib +0 -0
  265. netgen/lib/ngcore.lib +0 -0
  266. netgen/lib/nglib.lib +0 -0
  267. netgen/lib/togl.lib +0 -0
  268. netgen/libnggui.dll +0 -0
  269. netgen/libngguipy.lib +0 -0
  270. netgen/libngguipy.pyd +0 -0
  271. netgen/libngpy/_NgOCC.pyi +1545 -0
  272. netgen/libngpy/__init__.pyi +7 -0
  273. netgen/libngpy/_csg.pyi +259 -0
  274. netgen/libngpy/_geom2d.pyi +323 -0
  275. netgen/libngpy/_meshing.pyi +1111 -0
  276. netgen/libngpy/_stl.pyi +131 -0
  277. netgen/libngpy.lib +0 -0
  278. netgen/libngpy.pyd +0 -0
  279. netgen/meshing.py +65 -0
  280. netgen/ngcore.dll +0 -0
  281. netgen/nglib.dll +0 -0
  282. netgen/occ.py +52 -0
  283. netgen/read_gmsh.py +259 -0
  284. netgen/read_meshio.py +22 -0
  285. netgen/stl.py +2 -0
  286. netgen/togl.dll +0 -0
  287. netgen/version.py +2 -0
  288. netgen/webgui.py +529 -0
  289. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boundarycondition.geo +16 -0
  290. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boxcyl.geo +32 -0
  291. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/circle_on_cube.geo +27 -0
  292. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cone.geo +13 -0
  293. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cube.geo +16 -0
  294. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandring.geo +55 -0
  295. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandspheres.geo +21 -0
  296. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemcyl.geo +18 -0
  297. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemsphere.geo +19 -0
  298. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylinder.geo +12 -0
  299. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylsphere.geo +12 -0
  300. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/doc/ng4.pdf +0 -0
  301. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipsoid.geo +8 -0
  302. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipticcyl.geo +10 -0
  303. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/extrusion.geo +99 -0
  304. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/fichera.geo +24 -0
  305. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/frame.step +11683 -0
  306. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/hinge.stl +8486 -0
  307. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/lshape3d.geo +26 -0
  308. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes.geo +26 -0
  309. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes2.geo +26 -0
  310. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/matrix.geo +27 -0
  311. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ortho.geo +11 -0
  312. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/part1.stl +2662 -0
  313. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/period.geo +33 -0
  314. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/exportNeutral.py +26 -0
  315. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/mesh.py +19 -0
  316. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/shaft.geo +65 -0
  317. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/revolution.geo +18 -0
  318. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/screw.step +1694 -0
  319. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sculpture.geo +13 -0
  320. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shaft.geo +65 -0
  321. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shell.geo +10 -0
  322. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphere.geo +8 -0
  323. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphereincube.geo +17 -0
  324. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/square.in2d +35 -0
  325. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarecircle.in2d +48 -0
  326. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarehole.in2d +47 -0
  327. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/torus.geo +8 -0
  328. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/trafo.geo +57 -0
  329. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twobricks.geo +15 -0
  330. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocubes.geo +18 -0
  331. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocyl.geo +16 -0
  332. netgen_mesher-6.2.2506.post35.dev0.dist-info/METADATA +15 -0
  333. netgen_mesher-6.2.2506.post35.dev0.dist-info/RECORD +340 -0
  334. netgen_mesher-6.2.2506.post35.dev0.dist-info/WHEEL +5 -0
  335. netgen_mesher-6.2.2506.post35.dev0.dist-info/entry_points.txt +2 -0
  336. netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/AUTHORS +1 -0
  337. netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/LICENSE +504 -0
  338. netgen_mesher-6.2.2506.post35.dev0.dist-info/top_level.txt +2 -0
  339. pyngcore/__init__.py +1 -0
  340. pyngcore/pyngcore.cp314-win_amd64.pyd +0 -0
@@ -0,0 +1,858 @@
1
+ #ifndef FILE_GEOM2D
2
+ #define FILE_GEOM2D
3
+
4
+ /* *************************************************************************/
5
+ /* File: geom2d.hh */
6
+ /* Author: Joachim Schoeberl */
7
+ /* Date: 5. Aug. 95 */
8
+ /* *************************************************************************/
9
+
10
+ #include <mydefs.hpp>
11
+
12
+ #include <general/template.hpp>
13
+ #include "geomobjects.hpp"
14
+ #include <meshing/global.hpp>
15
+
16
+ namespace netgen
17
+ {
18
+
19
+ /* Geometric Algorithms */
20
+
21
+ #define EPSGEOM 1E-5
22
+
23
+
24
+ DLL_HEADER void MyError (const char * ch);
25
+
26
+ class Point2d;
27
+ class Vec2d;
28
+
29
+ class LINE2D;
30
+ class Line2d;
31
+ class PLine2d;
32
+ class TRIANGLE2D;
33
+ class PTRIANGLE2D;
34
+
35
+
36
+ inline Vec2d operator- (const Point2d & p1, const Point2d & p2);
37
+ inline Point2d operator- (const Point2d & p1, const Vec2d & v);
38
+ inline Point2d operator+ (const Point2d & p1, const Vec2d & v);
39
+ inline Point2d Center (const Point2d & p1, const Point2d & p2);
40
+
41
+ inline void PpSmV (const Point2d & p1, double s, const Vec2d & v, Point2d & p2);
42
+ inline void PmP (const Point2d & p1, const Point2d & p2, Vec2d & v);
43
+ ostream & operator<<(ostream & s, const Point2d & p);
44
+ inline Vec2d operator- (const Point2d & p1, const Point2d & p2);
45
+ inline Point2d operator- (const Point2d & p1, const Vec2d & v);
46
+ inline Point2d operator+ (const Point2d & p1, const Vec2d & v);
47
+ inline Vec2d operator- (const Vec2d & p1, const Vec2d & v);
48
+ inline Vec2d operator+ (const Vec2d & p1, const Vec2d & v);
49
+ inline Vec2d operator* (double scal, const Vec2d & v);
50
+ DLL_HEADER double Angle (const Vec2d & v);
51
+ DLL_HEADER double FastAngle (const Vec2d & v);
52
+ DLL_HEADER double Angle (const Vec2d & v1, const Vec2d & v2);
53
+ DLL_HEADER double FastAngle (const Vec2d & v1, const Vec2d & v2);
54
+ ostream & operator<<(ostream & s, const Vec2d & v);
55
+ double Dist2(const Line2d & g, const Line2d & h ); // GH
56
+ int Near (const Point2d & p1, const Point2d & p2, const double eps);
57
+
58
+ int Parallel (const Line2d & l1, const Line2d & l2, double peps = EPSGEOM);
59
+ int IsOnLine (const Line2d & l, const Point2d & p, double heps = EPSGEOM);
60
+ int IsOnLongLine (const Line2d & l, const Point2d & p);
61
+ int Hit (const Line2d & l1, const Line2d & l2, double heps = EPSGEOM);
62
+ ostream & operator<<(ostream & s, const Line2d & l);
63
+ DLL_HEADER Point2d CrossPoint (const PLine2d & l1, const PLine2d & l2);
64
+ DLL_HEADER Point2d CrossPoint (const Line2d & l1, const Line2d & l2);
65
+ int Parallel (const PLine2d & l1, const PLine2d & l2, double peps = EPSGEOM);
66
+ int IsOnLine (const PLine2d & l, const Point2d & p, double heps = EPSGEOM);
67
+ int IsOnLongLine (const PLine2d & l, const Point2d & p);
68
+ int Hit (const PLine2d & l1, const Line2d & l2, double heps = EPSGEOM);
69
+ ostream & operator<<(ostream & s, const Line2d & l);
70
+ ostream & operator<<(ostream & s, const TRIANGLE2D & t);
71
+ ostream & operator<<(ostream & s, const PTRIANGLE2D & t);
72
+ double Dist2 (const Point2d & p1, const Point2d & p2);
73
+
74
+ ///
75
+ class Point2d
76
+ {
77
+ ///
78
+ friend class Vec2d;
79
+
80
+ protected:
81
+ ///
82
+ double px, py;
83
+
84
+ public:
85
+ ///
86
+ Point2d() { /* px = py = 0; */ }
87
+ ///
88
+ Point2d(double ax, double ay) { px = ax; py = ay; }
89
+ ///
90
+ Point2d(const Point2d & p2) { px = p2.px; py = p2.py; }
91
+
92
+ Point2d (const Point<2> & p2)
93
+ {
94
+ px = p2(0);
95
+ py = p2(1);
96
+ }
97
+ ///
98
+ Point2d & operator= (const Point2d & p2)
99
+ { px = p2.px; py = p2.py; return *this; }
100
+
101
+ ///
102
+ int operator== (const Point2d & p2) const // GH
103
+ { return (px == p2.px && py == p2.py) ; }
104
+
105
+ ///
106
+ double & X() { return px; }
107
+ ///
108
+ double & Y() { return py; }
109
+ ///
110
+ double X() const { return px; }
111
+ ///
112
+ double Y() const { return py; }
113
+
114
+ operator Point<2> () const
115
+ {
116
+ return Point<2> (px, py);
117
+ }
118
+
119
+
120
+ ///
121
+ friend inline Vec2d operator- (const Point2d & p1, const Point2d & p2);
122
+ ///
123
+ friend inline Point2d operator- (const Point2d & p1, const Vec2d & v);
124
+ ///
125
+ friend inline Point2d operator+ (const Point2d & p1, const Vec2d & v);
126
+
127
+ ///
128
+ friend inline Point2d Center (const Point2d & p1, const Point2d & p2);
129
+
130
+ const Point2d & SetToMin (const Point2d & p2)
131
+ {
132
+ if (p2.px < px) px = p2.px;
133
+ if (p2.py < py) py = p2.py;
134
+ return *this;
135
+ }
136
+
137
+
138
+ ///
139
+ const Point2d & SetToMax (const Point2d & p2)
140
+ {
141
+ if (p2.px > px) px = p2.px;
142
+ if (p2.py > py) py = p2.py;
143
+ return *this;
144
+ }
145
+
146
+ ///
147
+ friend double Dist (const Point2d & p1, const Point2d & p2)
148
+ { return sqrt ( (p1.px - p2.px) * (p1.px - p2.px) +
149
+ (p1.py - p2.py) * (p1.py - p2.py) ); }
150
+ // { return sqrt ( sqr (p1.X()-p2.X()) + sqr (p1.Y()-p2.Y()) ); }
151
+
152
+ ///
153
+ friend double Dist2 (const Point2d & p1, const Point2d & p2)
154
+ { return ( (p1.px - p2.px) * (p1.px - p2.px) +
155
+ (p1.py - p2.py) * (p1.py - p2.py) ); }
156
+ // { return sqr (p1.X()-p2.X()) + sqr (p1.Y()-p2.Y()) ; }
157
+
158
+
159
+ /**
160
+ Points clock-wise ?
161
+ Are the points (p1, p2, p3) clock-wise ?
162
+ */
163
+ friend inline int CW (const Point2d & p1, const Point2d & p2, const Point2d & p3)
164
+ {
165
+ // return Cross (p2 - p1, p3 - p2) < 0;
166
+ return
167
+ (p2.px - p1.px) * (p3.py - p2.py) -
168
+ (p2.py - p1.py) * (p3.px - p2.px) < 0;
169
+ }
170
+ /**
171
+ Points counter-clock-wise ?
172
+ Are the points (p1, p2, p3) counter-clock-wise ?
173
+ */
174
+ friend inline bool CCW (const Point2d & p1, const Point2d & p2, const Point2d & p3)
175
+ {
176
+ // return Cross (p2 - p1, p3 - p2) > 0;
177
+ return
178
+ (p2.px - p1.px) * (p3.py - p2.py) -
179
+ (p2.py - p1.py) * (p3.px - p2.px) > 0;
180
+ } /**
181
+ Points counter-clock-wise ?
182
+ Are the points (p1, p2, p3) counter-clock-wise ?
183
+ */
184
+ friend inline bool CCW (const Point2d & p1, const Point2d & p2, const Point2d & p3, double eps)
185
+ {
186
+ // return Cross (p2 - p1, p3 - p2) > 0;
187
+ double ax = p2.px - p1.px;
188
+ double ay = p2.py - p1.py;
189
+ double bx = p3.px - p2.px;
190
+ double by = p3.py - p2.py;
191
+
192
+ return ax*by - ay*bx > eps*eps*max2(ax*ax+ay*ay,bx*bx+by*by);
193
+ }
194
+
195
+ ///
196
+ friend inline void PpSmV (const Point2d & p1, double s, const Vec2d & v, Point2d & p2);
197
+ ///
198
+ friend inline void PmP (const Point2d & p1, const Point2d & p2, Vec2d & v);
199
+
200
+ ///
201
+ friend ostream & operator<<(ostream & s, const Point2d & p);
202
+ };
203
+
204
+
205
+ inline int Near (const Point2d & p1, const Point2d & p2,
206
+ const double eps = 1e-4 )
207
+ {
208
+ return Dist2(p1,p2) <= eps*eps;
209
+ }
210
+
211
+
212
+
213
+
214
+
215
+
216
+ ///
217
+ class Vec2d
218
+ {
219
+ protected:
220
+ ///
221
+ double vx, vy;
222
+
223
+ public:
224
+ ///
225
+ Vec2d() { /* vx = vy = 0; */ }
226
+ ///
227
+ Vec2d(double ax, double ay)
228
+ { vx = ax; vy = ay; }
229
+ ///
230
+ Vec2d(const Vec2d & v2) { vx = v2.vx; vy = v2.vy; }
231
+
232
+ ///
233
+ explicit Vec2d(const Vec<2> & v2) { vx = v2(0); vy = v2(1); }
234
+
235
+ ///
236
+ Vec2d(const Point2d & p1, const Point2d & p2)
237
+ { vx = p2.px - p1.px; vy = p2.py - p1.py; }
238
+
239
+ ///
240
+ Vec2d & operator= (const Vec2d & p2)
241
+ { vx = p2.vx; vy = p2.vy; return *this; }
242
+
243
+ ///
244
+ double & X() { return vx; }
245
+ ///
246
+ double & Y() { return vy; }
247
+ ///
248
+ double X() const { return vx; }
249
+ ///
250
+ double Y() const { return vy; }
251
+
252
+ ///
253
+ double Length() const { return sqrt (vx * vx + vy * vy); }
254
+ ///
255
+ double Length2() const { return vx * vx + vy * vy; }
256
+
257
+ void GetNormal (Vec2d & n) const { n.vx=-vy; n.vy=vx; } // GH
258
+
259
+ ///
260
+ inline Vec2d & operator+= (const Vec2d & v2);
261
+ ///
262
+ inline Vec2d & operator-= (const Vec2d & v2);
263
+ ///
264
+ inline Vec2d & operator*= (double s);
265
+ ///
266
+ inline Vec2d & operator/= (double s);
267
+
268
+ ///
269
+ friend inline Vec2d operator- (const Point2d & p1, const Point2d & p2);
270
+ ///
271
+ friend inline Point2d operator- (const Point2d & p1, const Vec2d & v);
272
+ ///
273
+ friend inline Point2d operator+ (const Point2d & p1, const Vec2d & v);
274
+ ///
275
+ friend inline Vec2d operator- (const Vec2d & p1, const Vec2d & v);
276
+ ///
277
+ friend inline Vec2d operator+ (const Vec2d & p1, const Vec2d & v);
278
+ ///
279
+ friend inline Vec2d operator* (double scal, const Vec2d & v);
280
+
281
+ ///
282
+ friend double operator* (const Vec2d & v1, const Vec2d & v2)
283
+ { return v1.X() * v2.X() + v1.Y() * v2.Y(); }
284
+
285
+
286
+ ///
287
+ friend double Cross (const Vec2d & v1, const Vec2d & v2)
288
+ { return double(v1.X()) * double(v2.Y()) -
289
+ double(v1.Y()) * double(v2.X()); }
290
+
291
+ ///
292
+ friend inline void PpSmV (const Point2d & p1, double s, const Vec2d & v, Point2d & p2);
293
+ ///
294
+ friend inline void PmP (const Point2d & p1, const Point2d & p2, Vec2d & v);
295
+
296
+ /// Angle in [0,2*PI)
297
+
298
+ ///
299
+ friend DLL_HEADER double Angle (const Vec2d & v);
300
+ ///
301
+ friend DLL_HEADER double FastAngle (const Vec2d & v);
302
+ ///
303
+ friend DLL_HEADER double Angle (const Vec2d & v1, const Vec2d & v2);
304
+ ///
305
+ friend DLL_HEADER double FastAngle (const Vec2d & v1, const Vec2d & v2);
306
+
307
+ ///
308
+ friend ostream & operator<<(ostream & s, const Vec2d & v);
309
+ };
310
+
311
+
312
+
313
+ ///
314
+ class Line2d
315
+ {
316
+ protected:
317
+ ///
318
+ Point2d p1, p2;
319
+
320
+ public:
321
+ ///
322
+ Line2d() : p1(), p2() { };
323
+ ///
324
+ Line2d(const Point2d & ap1, const Point2d & ap2)
325
+ { p1 = ap1; p2 = ap2; }
326
+
327
+ ///
328
+ Line2d & operator= (const Line2d & l2)
329
+ { p1 = l2.p1; p2 = l2.p2; return *this;}
330
+
331
+ ///
332
+ Point2d & P1() { return p1; }
333
+ ///
334
+ Point2d & P2() { return p2; }
335
+ ///
336
+ const Point2d & P1() const { return p1; }
337
+ ///
338
+ const Point2d & P2() const { return p2; }
339
+
340
+ ///
341
+ double XMax() const { return max2 (p1.X(), p2.X()); }
342
+ ///
343
+ double YMax() const { return max2 (p1.Y(), p2.Y()); }
344
+ ///
345
+ double XMin() const { return min2 (p1.X(), p2.X()); }
346
+ ///
347
+ double YMin() const { return min2 (p1.Y(), p2.Y()); }
348
+
349
+ ///
350
+ Vec2d Delta () const { return Vec2d (p2.X()-p1.X(), p2.Y()-p1.Y()); }
351
+ ///
352
+ double Length () const { return Delta().Length(); }
353
+ ///
354
+ double Length2 () const
355
+ { return sqr (p1.X() - p2.X()) +
356
+ sqr (p1.Y() - p2.Y()); }
357
+
358
+ void GetNormal (Line2d & n) const; // GH
359
+ Vec2d NormalDelta () const; // GH
360
+
361
+ /// square of the distance between two 2d-lines.
362
+ friend double Dist2(const Line2d & g, const Line2d & h ); // GH
363
+
364
+ ///
365
+ friend DLL_HEADER Point2d CrossPoint (const Line2d & l1, const Line2d & l2);
366
+ /// returns 1 iff parallel
367
+ friend int CrossPointBarycentric (const Line2d & l1, const Line2d & l2,
368
+ double & lam1, double & lam2, double eps);
369
+
370
+ ///
371
+ friend int Parallel (const Line2d & l1, const Line2d & l2, double peps);
372
+ ///
373
+ friend int IsOnLine (const Line2d & l, const Point2d & p, double heps);
374
+ ///
375
+ friend int IsOnLongLine (const Line2d & l, const Point2d & p);
376
+ ///
377
+ friend int Hit (const Line2d & l1, const Line2d & l2, double heps);
378
+
379
+ ///
380
+ friend ostream & operator<<(ostream & s, const Line2d & l);
381
+ };
382
+
383
+
384
+ #ifdef NONE
385
+ ///
386
+ class PLine2d
387
+ {
388
+ protected:
389
+ ///
390
+ Point2d const * p1, *p2;
391
+
392
+ public:
393
+ ///
394
+ PLine2d() { };
395
+ ///
396
+ PLine2d(Point2d const * ap1, Point2d const * ap2)
397
+ { p1 = ap1; p2 = ap2; }
398
+
399
+ ///
400
+ PLine2d & operator= (const PLine2d & l2)
401
+ { p1 = l2.p1; p2 = l2.p2; return *this;}
402
+
403
+ ///
404
+ const Point2d *& P1() { return p1; }
405
+ ///
406
+ const Point2d *& P2() { return p2; }
407
+ ///
408
+ const Point2d & P1() const { return *p1; }
409
+ ///
410
+ const Point2d & P2() const { return *p2; }
411
+
412
+ ///
413
+ double XMax() const { return max2 (p1->X(), p2->X()); }
414
+ ///
415
+ double YMax() const { return max2 (p1->Y(), p2->Y()); }
416
+ ///
417
+ double XMin() const { return min2 (p1->X(), p2->X()); }
418
+ ///
419
+ double YMin() const { return min2 (p1->Y(), p2->Y()); }
420
+
421
+
422
+ ///
423
+ Vec2d Delta () const { return Vec2d (p2->X()-p1->X(), p2->Y()-p1->Y()); }
424
+ ///
425
+ double Length () const { return Delta().Length(); }
426
+ ///
427
+ double Length2 () const
428
+ { return sqr (p1->X() - p2->X()) +
429
+ sqr (p1->Y() - p2->Y()); }
430
+
431
+
432
+
433
+ ///
434
+ friend Point2d CrossPoint (const PLine2d & l1, const PLine2d & l2);
435
+ ///
436
+ friend int Parallel (const PLine2d & l1, const PLine2d & l2, double peps);
437
+ ///
438
+ friend int IsOnLine (const PLine2d & l, const Point2d & p, double heps);
439
+ ///
440
+ friend int IsOnLongLine (const PLine2d & l, const Point2d & p);
441
+ ///
442
+ friend int Hit (const PLine2d & l1, const Line2d & l2, double heps);
443
+
444
+ ///
445
+ friend ostream & operator<<(ostream & s, const Line2d & l);
446
+ };
447
+
448
+
449
+
450
+ ///
451
+ class ILINE
452
+ {
453
+ ///
454
+ INDEX i[2];
455
+
456
+ public:
457
+ ///
458
+ ILINE() {};
459
+ ///
460
+ ILINE(INDEX i1, INDEX i2) { i[0] = i1; i[1] = i2; }
461
+ ///
462
+ ILINE(const ILINE & l) { i[0] = l.i[0]; i[1] = l.i[1]; }
463
+
464
+ ///
465
+ ILINE & operator= (const ILINE & l)
466
+ { i[0] = l.i[0]; i[1] = l.i[1]; return *this; }
467
+
468
+ ///
469
+ const INDEX & I(int ai) const { return i[ai-1]; }
470
+ ///
471
+ const INDEX & X() const { return i[0]; }
472
+ ///
473
+ const INDEX & Y() const { return i[1]; }
474
+ ///
475
+ const INDEX & I1() const { return i[0]; }
476
+ ///
477
+ const INDEX & I2() const { return i[1]; }
478
+
479
+ ///
480
+ INDEX & I(int ai) { return i[ai-1]; }
481
+ ///
482
+ INDEX & X() { return i[0]; }
483
+ ///
484
+ INDEX & Y() { return i[1]; }
485
+ ///
486
+ INDEX & I1() { return i[0]; }
487
+ ///
488
+ INDEX & I2() { return i[1]; }
489
+ };
490
+
491
+
492
+
493
+
494
+ ///
495
+ class TRIANGLE2D
496
+ {
497
+ private:
498
+ ///
499
+ Point2d p1, p2, p3;
500
+
501
+ public:
502
+ ///
503
+ TRIANGLE2D() { };
504
+ ///
505
+ TRIANGLE2D (const Point2d & ap1, const Point2d & ap2,
506
+ const Point2d & ap3)
507
+ { p1 = ap1; p2 = ap2; p3 = ap3;}
508
+
509
+ ///
510
+ TRIANGLE2D & operator= (const TRIANGLE2D & t2)
511
+ { p1 = t2.p1; p2 = t2.p2; p3 = t2.p3; return *this; }
512
+
513
+ ///
514
+ Point2d & P1() { return p1; }
515
+ ///
516
+ Point2d & P2() { return p2; }
517
+ ///
518
+ Point2d & P3() { return p3; }
519
+ ///
520
+ const Point2d & P1() const { return p1; }
521
+ ///
522
+ const Point2d & P2() const { return p2; }
523
+ ///
524
+ const Point2d & P3() const { return p3; }
525
+
526
+ ///
527
+ double XMax() const { return max3 (p1.X(), p2.X(), p3.X()); }
528
+ ///
529
+ double YMax() const { return max3 (p1.Y(), p2.Y(), p3.Y()); }
530
+ ///
531
+ double XMin() const { return min3 (p1.X(), p2.X(), p3.X()); }
532
+ ///
533
+ double YMin() const { return min3 (p1.Y(), p2.Y(), p3.Y()); }
534
+
535
+ ///
536
+ inline Point2d Center () const
537
+ { return Point2d( (p1.X()+p2.X()+p3.X())/3, (p1.Y()+p2.Y()+p3.Y())/3); }
538
+
539
+ ///
540
+ int Regular() const;
541
+ ///
542
+ int CW () const;
543
+ ///
544
+ int CCW () const;
545
+
546
+ ///
547
+ int IsOn (const Point2d & p) const;
548
+ ///
549
+ int IsIn (const Point2d & p) const;
550
+ ///
551
+ friend ostream & operator<<(ostream & s, const TRIANGLE2D & t);
552
+ };
553
+
554
+
555
+ ///
556
+ class PTRIANGLE2D
557
+ {
558
+ private:
559
+ ///
560
+ Point2d const *p1, *p2, *p3;
561
+
562
+ public:
563
+ ///
564
+ PTRIANGLE2D() { };
565
+ ///
566
+ PTRIANGLE2D (const Point2d * ap1, const Point2d * ap2,
567
+ const Point2d * ap3)
568
+ { p1 = ap1; p2 = ap2; p3 = ap3;}
569
+
570
+ ///
571
+ PTRIANGLE2D & operator= (const PTRIANGLE2D & t2)
572
+ { p1 = t2.p1; p2 = t2.p2; p3 = t2.p3; return *this; }
573
+
574
+ ///
575
+ const Point2d *& P1() { return p1; }
576
+ ///
577
+ const Point2d *& P2() { return p2; }
578
+ ///
579
+ const Point2d *& P3() { return p3; }
580
+ ///
581
+ const Point2d * P1() const { return p1; }
582
+ ///
583
+ const Point2d * P2() const { return p2; }
584
+ ///
585
+ const Point2d * P3() const { return p3; }
586
+
587
+ ///
588
+ double XMax() const { return max3 (p1->X(), p2->X(), p3->X()); }
589
+ ///
590
+ double YMax() const { return max3 (p1->Y(), p2->Y(), p3->Y()); }
591
+ ///
592
+ double XMin() const { return min3 (p1->X(), p2->X(), p3->X()); }
593
+ ///
594
+ double YMin() const { return min3 (p1->Y(), p2->Y(), p3->Y()); }
595
+
596
+ ///
597
+ Point2d Center () const
598
+ { return Point2d( (p1->X()+p2->X()+p3->X())/3, (p1->Y()+p2->Y()+p3->Y())/3); }
599
+
600
+
601
+ ///
602
+ int Regular() const;
603
+ ///
604
+ int CW () const;
605
+ ///
606
+ int CCW () const;
607
+
608
+ ///
609
+ int IsOn (const Point2d & p) const;
610
+ ///
611
+ int IsIn (const Point2d & p) const;
612
+ ///
613
+ friend ostream & operator<<(ostream & s, const PTRIANGLE2D & t);
614
+ };
615
+ #endif
616
+
617
+
618
+ /** Cheap approximation to atan2.
619
+ A monotone function of atan2(x,y) is computed.
620
+ */
621
+ extern double Fastatan2 (double x, double y);
622
+
623
+
624
+ inline Vec2d & Vec2d :: operator+= (const Vec2d & v2)
625
+ {
626
+ vx += v2.vx;
627
+ vy += v2.vy;
628
+ return *this;
629
+ }
630
+
631
+ inline Vec2d & Vec2d :: operator-= (const Vec2d & v2)
632
+ {
633
+ vx -= v2.vx;
634
+ vy -= v2.vy;
635
+ return *this;
636
+ }
637
+
638
+ inline Vec2d & Vec2d :: operator*= (double s)
639
+ {
640
+ vx *= s;
641
+ vy *= s;
642
+ return *this;
643
+ }
644
+
645
+
646
+ inline Vec2d & Vec2d :: operator/= (double s)
647
+ {
648
+ if (s != 0)
649
+ {
650
+ vx /= s;
651
+ vy /= s;
652
+ }
653
+ else
654
+ {
655
+ MyError ("Vec2d::operator /=: Division by zero");
656
+ }
657
+ return *this;
658
+ }
659
+
660
+
661
+
662
+ inline Vec2d operator- (const Point2d & p1, const Point2d & p2)
663
+ {
664
+ return Vec2d (p1.X() - p2.X(), p1.Y() - p2.Y());
665
+ }
666
+
667
+
668
+ inline Point2d operator- (const Point2d & p1, const Vec2d & v)
669
+ {
670
+ return Point2d (p1.X() - v.X(), p1.Y() - v.Y());
671
+ }
672
+
673
+
674
+ inline Point2d operator+ (const Point2d & p1, const Vec2d & v)
675
+ {
676
+ return Point2d (p1.X() + v.X(), p1.Y() + v.Y());
677
+ }
678
+
679
+
680
+ inline Point2d Center (const Point2d & p1, const Point2d & p2)
681
+ {
682
+ return Point2d ((p1.X() + p2.X()) / 2, (p1.Y() + p2.Y()) / 2);
683
+ }
684
+
685
+
686
+ inline Vec2d operator- (const Vec2d & v1, const Vec2d & v2)
687
+ {
688
+ return Vec2d (v1.X() - v2.X(), v1.Y() - v2.Y());
689
+ }
690
+
691
+
692
+ inline Vec2d operator+ (const Vec2d & v1, const Vec2d & v2)
693
+ {
694
+ return Vec2d (v1.X() + v2.X(), v1.Y() + v2.Y());
695
+ }
696
+
697
+
698
+ inline Vec2d operator* (double scal, const Vec2d & v)
699
+ {
700
+ return Vec2d (scal * v.X(), scal * v.Y());
701
+ }
702
+
703
+
704
+ inline void PpSmV (const Point2d & p1, double s,
705
+ const Vec2d & v, Point2d & p2)
706
+ {
707
+ p2.X() = p1.X() + s * v.X();
708
+ p2.Y() = p1.Y() + s * v.Y();
709
+ }
710
+
711
+
712
+ inline void PmP (const Point2d & p1, const Point2d & p2, Vec2d & v)
713
+ {
714
+ v.X() = p1.X() - p2.X();
715
+ v.Y() = p1.Y() - p2.Y();
716
+ }
717
+
718
+
719
+
720
+
721
+
722
+ #ifdef none
723
+ inline int TRIANGLE2D :: Regular() const
724
+ {
725
+ return fabs(Cross ( p2 - p1, p3 - p2)) > EPSGEOM;
726
+ }
727
+
728
+
729
+ inline int TRIANGLE2D :: CW () const
730
+ {
731
+ return Cross ( p2 - p1, p3 - p2) < 0;
732
+ }
733
+
734
+
735
+ inline int TRIANGLE2D :: CCW () const
736
+ {
737
+ return Cross ( p2 - p1, p3 - p2) > 0;
738
+ }
739
+
740
+
741
+
742
+
743
+ inline int PTRIANGLE2D :: Regular() const
744
+ {
745
+ return fabs(Cross ( *p2 - *p1, *p3 - *p2)) > EPSGEOM;
746
+ }
747
+
748
+
749
+ inline int PTRIANGLE2D :: CW () const
750
+ {
751
+ return Cross ( *p2 - *p1, *p3 - *p2) < 0;
752
+ }
753
+
754
+
755
+ inline int PTRIANGLE2D :: CCW () const
756
+ {
757
+ return Cross ( *p2 - *p1, *p3 - *p2) > 0;
758
+ }
759
+
760
+
761
+ #endif
762
+
763
+
764
+ ///
765
+ class Mat2d
766
+ {
767
+ protected:
768
+ ///
769
+ double coeff[4];
770
+
771
+ public:
772
+ ///
773
+ Mat2d() { coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0; }
774
+ ///
775
+ Mat2d(double a11, double a12, double a21, double a22)
776
+ { coeff[0] = a11; coeff[1] = a12; coeff[2] = a21; coeff[3] = a22; }
777
+ ///
778
+ Mat2d(const Mat2d & m2)
779
+ { for (int i = 0; i < 4; i++) coeff[i] = m2.Get(i); }
780
+
781
+ ///
782
+ double & Elem (INDEX i, INDEX j) { return coeff[2*(i-1)+j-1]; }
783
+ ///
784
+ double & Elem (INDEX i) {return coeff[i]; }
785
+ ///
786
+ double Get (INDEX i, INDEX j) const { return coeff[2*(i-1)+j-1]; }
787
+ ///
788
+ double Get (INDEX i) const {return coeff[i]; }
789
+
790
+ ///
791
+ double Det () const { return coeff[0] * coeff[3] - coeff[1] * coeff[2]; }
792
+
793
+ ///
794
+ void Mult (const Vec2d & v, Vec2d & prod) const;
795
+ ///
796
+ void MultTrans (const Vec2d & v , Vec2d & prod) const;
797
+ ///
798
+ void Solve (const Vec2d & rhs, Vec2d & x) const;
799
+ /// Solves mat * x = rhs, but using a positive definite matrix instead of mat
800
+ void SolvePositiveDefinite (const Vec2d & rhs, Vec2d & x) const;
801
+ /// add a term \alpha * v * v^T
802
+ void AddDiadicProduct (double alpha, Vec2d & v);
803
+ };
804
+
805
+
806
+
807
+ inline void Mat2d :: Mult (const Vec2d & v, Vec2d & prod) const
808
+ {
809
+ prod.X() = coeff[0] * v.X() + coeff[1] * v.Y();
810
+ prod.Y() = coeff[2] * v.X() + coeff[3] * v.Y();
811
+ }
812
+
813
+
814
+ inline void Mat2d :: MultTrans (const Vec2d & v, Vec2d & prod) const
815
+ {
816
+ prod.X() = coeff[0] * v.X() + coeff[2] * v.Y();
817
+ prod.Y() = coeff[1] * v.X() + coeff[3] * v.Y();
818
+ }
819
+
820
+
821
+
822
+ inline void Mat2d :: Solve (const Vec2d & rhs, Vec2d & x) const
823
+ {
824
+ double det = Det();
825
+
826
+ if (det == 0)
827
+ MyError ("Mat2d::Solve: zero determinant");
828
+ else
829
+ {
830
+ x.X() = (coeff[3] * rhs.X() - coeff[1] * rhs.Y()) / det;
831
+ x.Y() = (-coeff[2] * rhs.X() + coeff[0] * rhs.Y()) / det;
832
+ }
833
+ }
834
+
835
+
836
+ inline void Mat2d :: SolvePositiveDefinite (const Vec2d & rhs, Vec2d & x) const
837
+ {
838
+ double a = max2(coeff[0], 1e-8);
839
+ double b = coeff[1] / a;
840
+ double c = coeff[2] / a;
841
+ double d = max2(coeff[3] - a *b * c, 1e-8);
842
+
843
+ x.X() = (rhs.X() - b * rhs.Y()) / a;
844
+ x.Y() = rhs.Y() / d - c * x.X();
845
+ }
846
+
847
+
848
+ inline void Mat2d :: AddDiadicProduct (double alpha, Vec2d & v)
849
+ {
850
+ coeff[0] += alpha * v.X() * v.X();
851
+ coeff[1] += alpha * v.X() * v.Y();
852
+ coeff[2] += alpha * v.Y() * v.X();
853
+ coeff[3] += alpha * v.Y() * v.Y();
854
+ }
855
+
856
+ }
857
+
858
+ #endif