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.
- netgen/NgOCC.py +7 -0
- netgen/__init__.py +114 -0
- netgen/__init__.pyi +22 -0
- netgen/__main__.py +53 -0
- netgen/cmake/NetgenConfig.cmake +79 -0
- netgen/cmake/netgen-targets-release.cmake +69 -0
- netgen/cmake/netgen-targets.cmake +146 -0
- netgen/config/__init__.py +1 -0
- netgen/config/__init__.pyi +52 -0
- netgen/config/__main__.py +4 -0
- netgen/config/config.py +68 -0
- netgen/config/config.pyi +54 -0
- netgen/csg.py +25 -0
- netgen/geom2d.py +178 -0
- netgen/gui.py +82 -0
- netgen/include/core/archive.hpp +1256 -0
- netgen/include/core/array.hpp +1760 -0
- netgen/include/core/autodiff.hpp +1131 -0
- netgen/include/core/autodiffdiff.hpp +733 -0
- netgen/include/core/bitarray.hpp +240 -0
- netgen/include/core/concurrentqueue.h +3619 -0
- netgen/include/core/exception.hpp +145 -0
- netgen/include/core/flags.hpp +199 -0
- netgen/include/core/hashtable.hpp +1281 -0
- netgen/include/core/localheap.hpp +318 -0
- netgen/include/core/logging.hpp +117 -0
- netgen/include/core/memtracer.hpp +221 -0
- netgen/include/core/mpi4py_pycapi.h +245 -0
- netgen/include/core/mpi_wrapper.hpp +643 -0
- netgen/include/core/ng_mpi.hpp +94 -0
- netgen/include/core/ng_mpi_generated_declarations.hpp +155 -0
- netgen/include/core/ng_mpi_native.hpp +25 -0
- netgen/include/core/ngcore.hpp +32 -0
- netgen/include/core/ngcore_api.hpp +152 -0
- netgen/include/core/ngstream.hpp +115 -0
- netgen/include/core/paje_trace.hpp +279 -0
- netgen/include/core/profiler.hpp +382 -0
- netgen/include/core/python_ngcore.hpp +457 -0
- netgen/include/core/ranges.hpp +109 -0
- netgen/include/core/register_archive.hpp +100 -0
- netgen/include/core/signal.hpp +82 -0
- netgen/include/core/simd.hpp +160 -0
- netgen/include/core/simd_arm64.hpp +407 -0
- netgen/include/core/simd_avx.hpp +394 -0
- netgen/include/core/simd_avx512.hpp +285 -0
- netgen/include/core/simd_generic.hpp +1053 -0
- netgen/include/core/simd_math.hpp +178 -0
- netgen/include/core/simd_sse.hpp +289 -0
- netgen/include/core/statushandler.hpp +37 -0
- netgen/include/core/symboltable.hpp +153 -0
- netgen/include/core/table.hpp +810 -0
- netgen/include/core/taskmanager.hpp +1161 -0
- netgen/include/core/type_traits.hpp +65 -0
- netgen/include/core/utils.hpp +385 -0
- netgen/include/core/version.hpp +102 -0
- netgen/include/core/xbool.hpp +47 -0
- netgen/include/csg/algprim.hpp +563 -0
- netgen/include/csg/brick.hpp +150 -0
- netgen/include/csg/csg.hpp +43 -0
- netgen/include/csg/csgeom.hpp +389 -0
- netgen/include/csg/csgparser.hpp +101 -0
- netgen/include/csg/curve2d.hpp +67 -0
- netgen/include/csg/edgeflw.hpp +112 -0
- netgen/include/csg/explicitcurve2d.hpp +113 -0
- netgen/include/csg/extrusion.hpp +185 -0
- netgen/include/csg/gencyl.hpp +70 -0
- netgen/include/csg/geoml.hpp +16 -0
- netgen/include/csg/identify.hpp +213 -0
- netgen/include/csg/manifold.hpp +29 -0
- netgen/include/csg/meshsurf.hpp +46 -0
- netgen/include/csg/polyhedra.hpp +121 -0
- netgen/include/csg/revolution.hpp +180 -0
- netgen/include/csg/singularref.hpp +84 -0
- netgen/include/csg/solid.hpp +295 -0
- netgen/include/csg/specpoin.hpp +194 -0
- netgen/include/csg/spline3d.hpp +99 -0
- netgen/include/csg/splinesurface.hpp +85 -0
- netgen/include/csg/surface.hpp +394 -0
- netgen/include/csg/triapprox.hpp +63 -0
- netgen/include/csg/vscsg.hpp +34 -0
- netgen/include/general/autodiff.hpp +356 -0
- netgen/include/general/autoptr.hpp +39 -0
- netgen/include/general/gzstream.h +121 -0
- netgen/include/general/hashtabl.hpp +1692 -0
- netgen/include/general/myadt.hpp +48 -0
- netgen/include/general/mystring.hpp +226 -0
- netgen/include/general/netgenout.hpp +205 -0
- netgen/include/general/ngarray.hpp +797 -0
- netgen/include/general/ngbitarray.hpp +149 -0
- netgen/include/general/ngpython.hpp +74 -0
- netgen/include/general/optmem.hpp +44 -0
- netgen/include/general/parthreads.hpp +138 -0
- netgen/include/general/seti.hpp +50 -0
- netgen/include/general/sort.hpp +47 -0
- netgen/include/general/spbita2d.hpp +59 -0
- netgen/include/general/stack.hpp +114 -0
- netgen/include/general/table.hpp +280 -0
- netgen/include/general/template.hpp +509 -0
- netgen/include/geom2d/csg2d.hpp +750 -0
- netgen/include/geom2d/geometry2d.hpp +280 -0
- netgen/include/geom2d/spline2d.hpp +234 -0
- netgen/include/geom2d/vsgeom2d.hpp +28 -0
- netgen/include/gprim/adtree.hpp +1392 -0
- netgen/include/gprim/geom2d.hpp +858 -0
- netgen/include/gprim/geom3d.hpp +749 -0
- netgen/include/gprim/geomfuncs.hpp +212 -0
- netgen/include/gprim/geomobjects.hpp +544 -0
- netgen/include/gprim/geomops.hpp +404 -0
- netgen/include/gprim/geomtest3d.hpp +101 -0
- netgen/include/gprim/gprim.hpp +33 -0
- netgen/include/gprim/spline.hpp +778 -0
- netgen/include/gprim/splinegeometry.hpp +73 -0
- netgen/include/gprim/transform3d.hpp +216 -0
- netgen/include/include/acisgeom.hpp +3 -0
- netgen/include/include/csg.hpp +1 -0
- netgen/include/include/geometry2d.hpp +1 -0
- netgen/include/include/gprim.hpp +1 -0
- netgen/include/include/incopengl.hpp +62 -0
- netgen/include/include/inctcl.hpp +13 -0
- netgen/include/include/incvis.hpp +6 -0
- netgen/include/include/linalg.hpp +1 -0
- netgen/include/include/meshing.hpp +1 -0
- netgen/include/include/myadt.hpp +1 -0
- netgen/include/include/mydefs.hpp +70 -0
- netgen/include/include/mystdlib.h +59 -0
- netgen/include/include/netgen_config.hpp +27 -0
- netgen/include/include/netgen_version.hpp +9 -0
- netgen/include/include/nginterface_v2_impl.hpp +395 -0
- netgen/include/include/ngsimd.hpp +1 -0
- netgen/include/include/occgeom.hpp +1 -0
- netgen/include/include/opti.hpp +1 -0
- netgen/include/include/parallel.hpp +1 -0
- netgen/include/include/stlgeom.hpp +1 -0
- netgen/include/include/visual.hpp +1 -0
- netgen/include/interface/rw_medit.hpp +11 -0
- netgen/include/interface/writeuser.hpp +80 -0
- netgen/include/linalg/densemat.hpp +414 -0
- netgen/include/linalg/linalg.hpp +29 -0
- netgen/include/linalg/opti.hpp +142 -0
- netgen/include/linalg/polynomial.hpp +47 -0
- netgen/include/linalg/vector.hpp +217 -0
- netgen/include/meshing/adfront2.hpp +274 -0
- netgen/include/meshing/adfront3.hpp +332 -0
- netgen/include/meshing/basegeom.hpp +370 -0
- netgen/include/meshing/bcfunctions.hpp +53 -0
- netgen/include/meshing/bisect.hpp +72 -0
- netgen/include/meshing/boundarylayer.hpp +113 -0
- netgen/include/meshing/classifyhpel.hpp +1984 -0
- netgen/include/meshing/clusters.hpp +46 -0
- netgen/include/meshing/curvedelems.hpp +274 -0
- netgen/include/meshing/delaunay2d.hpp +73 -0
- netgen/include/meshing/fieldlines.hpp +103 -0
- netgen/include/meshing/findip.hpp +198 -0
- netgen/include/meshing/findip2.hpp +103 -0
- netgen/include/meshing/geomsearch.hpp +69 -0
- netgen/include/meshing/global.hpp +54 -0
- netgen/include/meshing/hpref_hex.hpp +330 -0
- netgen/include/meshing/hpref_prism.hpp +3405 -0
- netgen/include/meshing/hpref_pyramid.hpp +154 -0
- netgen/include/meshing/hpref_quad.hpp +2082 -0
- netgen/include/meshing/hpref_segm.hpp +122 -0
- netgen/include/meshing/hpref_tet.hpp +4230 -0
- netgen/include/meshing/hpref_trig.hpp +848 -0
- netgen/include/meshing/hprefinement.hpp +366 -0
- netgen/include/meshing/improve2.hpp +178 -0
- netgen/include/meshing/improve3.hpp +151 -0
- netgen/include/meshing/localh.hpp +223 -0
- netgen/include/meshing/meshclass.hpp +1076 -0
- netgen/include/meshing/meshfunc.hpp +47 -0
- netgen/include/meshing/meshing.hpp +63 -0
- netgen/include/meshing/meshing2.hpp +163 -0
- netgen/include/meshing/meshing3.hpp +123 -0
- netgen/include/meshing/meshtool.hpp +90 -0
- netgen/include/meshing/meshtype.hpp +1930 -0
- netgen/include/meshing/msghandler.hpp +62 -0
- netgen/include/meshing/paralleltop.hpp +172 -0
- netgen/include/meshing/python_mesh.hpp +206 -0
- netgen/include/meshing/ruler2.hpp +172 -0
- netgen/include/meshing/ruler3.hpp +211 -0
- netgen/include/meshing/soldata.hpp +141 -0
- netgen/include/meshing/specials.hpp +17 -0
- netgen/include/meshing/surfacegeom.hpp +73 -0
- netgen/include/meshing/topology.hpp +1003 -0
- netgen/include/meshing/validate.hpp +21 -0
- netgen/include/meshing/visual_interface.hpp +71 -0
- netgen/include/mydefs.hpp +70 -0
- netgen/include/nginterface.h +474 -0
- netgen/include/nginterface_v2.hpp +406 -0
- netgen/include/nglib.h +697 -0
- netgen/include/nglib_occ.h +50 -0
- netgen/include/occ/occ_edge.hpp +47 -0
- netgen/include/occ/occ_face.hpp +52 -0
- netgen/include/occ/occ_solid.hpp +23 -0
- netgen/include/occ/occ_utils.hpp +376 -0
- netgen/include/occ/occ_vertex.hpp +30 -0
- netgen/include/occ/occgeom.hpp +659 -0
- netgen/include/occ/occmeshsurf.hpp +168 -0
- netgen/include/occ/vsocc.hpp +33 -0
- netgen/include/pybind11/LICENSE +29 -0
- netgen/include/pybind11/attr.h +722 -0
- netgen/include/pybind11/buffer_info.h +208 -0
- netgen/include/pybind11/cast.h +2361 -0
- netgen/include/pybind11/chrono.h +228 -0
- netgen/include/pybind11/common.h +2 -0
- netgen/include/pybind11/complex.h +74 -0
- netgen/include/pybind11/conduit/README.txt +15 -0
- netgen/include/pybind11/conduit/pybind11_conduit_v1.h +116 -0
- netgen/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
- netgen/include/pybind11/conduit/wrap_include_python_h.h +72 -0
- netgen/include/pybind11/critical_section.h +56 -0
- netgen/include/pybind11/detail/class.h +823 -0
- netgen/include/pybind11/detail/common.h +1348 -0
- netgen/include/pybind11/detail/cpp_conduit.h +75 -0
- netgen/include/pybind11/detail/descr.h +226 -0
- netgen/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
- netgen/include/pybind11/detail/exception_translation.h +71 -0
- netgen/include/pybind11/detail/function_record_pyobject.h +191 -0
- netgen/include/pybind11/detail/init.h +538 -0
- netgen/include/pybind11/detail/internals.h +799 -0
- netgen/include/pybind11/detail/native_enum_data.h +209 -0
- netgen/include/pybind11/detail/pybind11_namespace_macros.h +82 -0
- netgen/include/pybind11/detail/struct_smart_holder.h +378 -0
- netgen/include/pybind11/detail/type_caster_base.h +1591 -0
- netgen/include/pybind11/detail/typeid.h +65 -0
- netgen/include/pybind11/detail/using_smart_holder.h +22 -0
- netgen/include/pybind11/detail/value_and_holder.h +90 -0
- netgen/include/pybind11/eigen/common.h +9 -0
- netgen/include/pybind11/eigen/matrix.h +723 -0
- netgen/include/pybind11/eigen/tensor.h +521 -0
- netgen/include/pybind11/eigen.h +12 -0
- netgen/include/pybind11/embed.h +320 -0
- netgen/include/pybind11/eval.h +161 -0
- netgen/include/pybind11/functional.h +147 -0
- netgen/include/pybind11/gil.h +199 -0
- netgen/include/pybind11/gil_safe_call_once.h +102 -0
- netgen/include/pybind11/gil_simple.h +37 -0
- netgen/include/pybind11/iostream.h +265 -0
- netgen/include/pybind11/native_enum.h +67 -0
- netgen/include/pybind11/numpy.h +2312 -0
- netgen/include/pybind11/operators.h +202 -0
- netgen/include/pybind11/options.h +92 -0
- netgen/include/pybind11/pybind11.h +3645 -0
- netgen/include/pybind11/pytypes.h +2680 -0
- netgen/include/pybind11/stl/filesystem.h +114 -0
- netgen/include/pybind11/stl.h +666 -0
- netgen/include/pybind11/stl_bind.h +858 -0
- netgen/include/pybind11/subinterpreter.h +299 -0
- netgen/include/pybind11/trampoline_self_life_support.h +65 -0
- netgen/include/pybind11/type_caster_pyobject_ptr.h +61 -0
- netgen/include/pybind11/typing.h +298 -0
- netgen/include/pybind11/warnings.h +75 -0
- netgen/include/stlgeom/meshstlsurface.hpp +67 -0
- netgen/include/stlgeom/stlgeom.hpp +491 -0
- netgen/include/stlgeom/stlline.hpp +193 -0
- netgen/include/stlgeom/stltool.hpp +331 -0
- netgen/include/stlgeom/stltopology.hpp +419 -0
- netgen/include/stlgeom/vsstl.hpp +58 -0
- netgen/include/visualization/meshdoc.hpp +42 -0
- netgen/include/visualization/mvdraw.hpp +325 -0
- netgen/include/visualization/vispar.hpp +128 -0
- netgen/include/visualization/visual.hpp +28 -0
- netgen/include/visualization/visual_api.hpp +10 -0
- netgen/include/visualization/vssolution.hpp +399 -0
- netgen/lib/libnggui.lib +0 -0
- netgen/lib/ngcore.lib +0 -0
- netgen/lib/nglib.lib +0 -0
- netgen/lib/togl.lib +0 -0
- netgen/libnggui.dll +0 -0
- netgen/libngguipy.lib +0 -0
- netgen/libngguipy.pyd +0 -0
- netgen/libngpy/_NgOCC.pyi +1545 -0
- netgen/libngpy/__init__.pyi +7 -0
- netgen/libngpy/_csg.pyi +259 -0
- netgen/libngpy/_geom2d.pyi +323 -0
- netgen/libngpy/_meshing.pyi +1111 -0
- netgen/libngpy/_stl.pyi +131 -0
- netgen/libngpy.lib +0 -0
- netgen/libngpy.pyd +0 -0
- netgen/meshing.py +65 -0
- netgen/ngcore.dll +0 -0
- netgen/nglib.dll +0 -0
- netgen/occ.py +52 -0
- netgen/read_gmsh.py +259 -0
- netgen/read_meshio.py +22 -0
- netgen/stl.py +2 -0
- netgen/togl.dll +0 -0
- netgen/version.py +2 -0
- netgen/webgui.py +529 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boundarycondition.geo +16 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boxcyl.geo +32 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/circle_on_cube.geo +27 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cone.geo +13 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cube.geo +16 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandring.geo +55 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandspheres.geo +21 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemcyl.geo +18 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemsphere.geo +19 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylinder.geo +12 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylsphere.geo +12 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/doc/ng4.pdf +0 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipsoid.geo +8 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipticcyl.geo +10 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/extrusion.geo +99 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/fichera.geo +24 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/frame.step +11683 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/hinge.stl +8486 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/lshape3d.geo +26 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes.geo +26 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes2.geo +26 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/matrix.geo +27 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ortho.geo +11 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/part1.stl +2662 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/period.geo +33 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/exportNeutral.py +26 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/mesh.py +19 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/shaft.geo +65 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/revolution.geo +18 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/screw.step +1694 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sculpture.geo +13 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shaft.geo +65 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shell.geo +10 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphere.geo +8 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphereincube.geo +17 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/square.in2d +35 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarecircle.in2d +48 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarehole.in2d +47 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/torus.geo +8 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/trafo.geo +57 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twobricks.geo +15 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocubes.geo +18 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocyl.geo +16 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/METADATA +15 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/RECORD +340 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/WHEEL +5 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/entry_points.txt +2 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/AUTHORS +1 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/LICENSE +504 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/top_level.txt +2 -0
- pyngcore/__init__.py +1 -0
- 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
|