toxiclibs 0.2-java → 0.5.0-java
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.
- checksums.yaml +4 -4
- data/.gitignore +16 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE +675 -0
- data/README.md +12 -5
- data/Rakefile +25 -82
- data/examples/attract_repel/attract_repel.rb +30 -0
- data/examples/attract_repel/attractor.rb +23 -0
- data/examples/attract_repel/particle.rb +27 -0
- data/examples/data/ti_yong.png +0 -0
- data/examples/force_directed/cluster.rb +76 -0
- data/examples/force_directed/force_directed_graph.rb +92 -0
- data/examples/force_directed/node.rb +26 -0
- data/examples/gray_scott_image.rb +75 -0
- data/examples/gray_scott_tone_map.rb +77 -0
- data/examples/implicit.rb +139 -0
- data/examples/inflate_mesh.rb +89 -0
- data/examples/model_align.rb +44 -0
- data/examples/povmesh/ftest.rb +46 -0
- data/examples/povmesh/tentacle.rb +73 -0
- data/examples/simple_cluster/cluster.rb +47 -0
- data/examples/simple_cluster/node.rb +27 -0
- data/examples/simple_cluster/simple_cluster.rb +60 -0
- data/examples/soft_body/blanket.rb +45 -0
- data/examples/soft_body/connection.rb +16 -0
- data/examples/soft_body/particle.rb +22 -0
- data/examples/soft_body/soft_body_square_adapted.rb +55 -0
- data/lib/toxiclibs.jar +0 -0
- data/lib/toxiclibs.rb +91 -32
- data/lib/toxiclibs/version.rb +1 -1
- data/pom.xml +122 -0
- data/src/com/toxi/net/ClientListener.java +41 -0
- data/src/com/toxi/net/ServerListener.java +70 -0
- data/src/com/toxi/net/ServerListenerAdapter.java +47 -0
- data/src/com/toxi/net/ServerState.java +18 -0
- data/src/com/toxi/net/UDPConnection.java +66 -0
- data/src/com/toxi/net/UDPSyncClient.java +81 -0
- data/src/com/toxi/net/UDPSyncServer.java +450 -0
- data/src/com/toxi/nio/UDPClient.java +121 -0
- data/src/com/toxi/nio/UDPClientState.java +32 -0
- data/src/com/toxi/nio/UDPServer.java +129 -0
- data/src/toxi/color/AccessCriteria.java +114 -0
- data/src/toxi/color/AlphaAccessor.java +67 -0
- data/src/toxi/color/CMYKAccessor.java +122 -0
- data/src/toxi/color/CMYKDistanceProxy.java +40 -0
- data/src/toxi/color/ColorGradient.java +260 -0
- data/src/toxi/color/ColorList.java +699 -0
- data/src/toxi/color/ColorRange.java +671 -0
- data/src/toxi/color/ColorTheme.java +163 -0
- data/src/toxi/color/DistanceProxy.java +44 -0
- data/src/toxi/color/HSVAccessor.java +113 -0
- data/src/toxi/color/HSVDistanceProxy.java +40 -0
- data/src/toxi/color/HistEntry.java +85 -0
- data/src/toxi/color/Histogram.java +185 -0
- data/src/toxi/color/Hue.java +249 -0
- data/src/toxi/color/LuminanceAccessor.java +78 -0
- data/src/toxi/color/NamedColor.java +935 -0
- data/src/toxi/color/ProximityComparator.java +70 -0
- data/src/toxi/color/RGBAccessor.java +113 -0
- data/src/toxi/color/RGBDistanceProxy.java +41 -0
- data/src/toxi/color/ReadonlyTColor.java +296 -0
- data/src/toxi/color/TColor.java +1677 -0
- data/src/toxi/color/TColorAdapter.java +68 -0
- data/src/toxi/color/ToneMap.java +218 -0
- data/src/toxi/color/theory/AnalogousStrategy.java +140 -0
- data/src/toxi/color/theory/ColorTheoryRegistry.java +139 -0
- data/src/toxi/color/theory/ColorTheoryStrategy.java +56 -0
- data/src/toxi/color/theory/ComplementaryStrategy.java +111 -0
- data/src/toxi/color/theory/CompoundTheoryStrategy.java +143 -0
- data/src/toxi/color/theory/LeftSplitComplementaryStrategy.java +82 -0
- data/src/toxi/color/theory/MonochromeTheoryStrategy.java +103 -0
- data/src/toxi/color/theory/RightSplitComplementaryStrategy.java +82 -0
- data/src/toxi/color/theory/SingleComplementStrategy.java +76 -0
- data/src/toxi/color/theory/SplitComplementaryStrategy.java +77 -0
- data/src/toxi/color/theory/TetradTheoryStrategy.java +114 -0
- data/src/toxi/color/theory/TriadTheoryStrategy.java +77 -0
- data/src/toxi/data/csv/CSVAdapter.java +74 -0
- data/src/toxi/data/csv/CSVFieldMapper.java +212 -0
- data/src/toxi/data/csv/CSVListener.java +61 -0
- data/src/toxi/data/csv/CSVParser.java +202 -0
- data/src/toxi/data/feeds/AtomAuthor.java +49 -0
- data/src/toxi/data/feeds/AtomContent.java +50 -0
- data/src/toxi/data/feeds/AtomEntry.java +111 -0
- data/src/toxi/data/feeds/AtomFeed.java +129 -0
- data/src/toxi/data/feeds/AtomLink.java +62 -0
- data/src/toxi/data/feeds/RSSChannel.java +88 -0
- data/src/toxi/data/feeds/RSSEnclosure.java +60 -0
- data/src/toxi/data/feeds/RSSFeed.java +99 -0
- data/src/toxi/data/feeds/RSSItem.java +104 -0
- data/src/toxi/data/feeds/util/EntityStripper.java +2480 -0
- data/src/toxi/data/feeds/util/Iso8601DateAdapter.java +101 -0
- data/src/toxi/data/feeds/util/Rfc822DateAdapter.java +93 -0
- data/src/toxi/geom/AABB.java +658 -0
- data/src/toxi/geom/Axis3D.java +116 -0
- data/src/toxi/geom/AxisAlignedCylinder.java +163 -0
- data/src/toxi/geom/BernsteinPolynomial.java +94 -0
- data/src/toxi/geom/BezierCurve2D.java +159 -0
- data/src/toxi/geom/BezierCurve3D.java +148 -0
- data/src/toxi/geom/BooleanShapeBuilder.java +185 -0
- data/src/toxi/geom/BoxIntersector.java +52 -0
- data/src/toxi/geom/Circle.java +230 -0
- data/src/toxi/geom/CircleIntersector.java +85 -0
- data/src/toxi/geom/Cone.java +150 -0
- data/src/toxi/geom/ConvexPolygonClipper.java +136 -0
- data/src/toxi/geom/CoordinateExtractor.java +16 -0
- data/src/toxi/geom/Ellipse.java +250 -0
- data/src/toxi/geom/GMatrix.java +2599 -0
- data/src/toxi/geom/GVector.java +833 -0
- data/src/toxi/geom/GlobalGridTesselator.java +54 -0
- data/src/toxi/geom/GridTesselator.java +108 -0
- data/src/toxi/geom/Intersector2D.java +49 -0
- data/src/toxi/geom/Intersector3D.java +51 -0
- data/src/toxi/geom/IsectData2D.java +103 -0
- data/src/toxi/geom/IsectData3D.java +103 -0
- data/src/toxi/geom/Line2D.java +534 -0
- data/src/toxi/geom/Line3D.java +471 -0
- data/src/toxi/geom/LineStrip2D.java +430 -0
- data/src/toxi/geom/LineStrip3D.java +230 -0
- data/src/toxi/geom/LocalGridTesselator.java +57 -0
- data/src/toxi/geom/Matrix3d.java +3048 -0
- data/src/toxi/geom/Matrix4f.java +3446 -0
- data/src/toxi/geom/Matrix4x4.java +1076 -0
- data/src/toxi/geom/MatrixSizeException.java +58 -0
- data/src/toxi/geom/OctreeVisitor.java +44 -0
- data/src/toxi/geom/Origin3D.java +148 -0
- data/src/toxi/geom/Plane.java +293 -0
- data/src/toxi/geom/PlaneIntersector.java +57 -0
- data/src/toxi/geom/PointCloud3D.java +253 -0
- data/src/toxi/geom/PointOctree.java +502 -0
- data/src/toxi/geom/PointQuadtree.java +375 -0
- data/src/toxi/geom/Polygon2D.java +1038 -0
- data/src/toxi/geom/PolygonClipper2D.java +45 -0
- data/src/toxi/geom/PolygonTesselator.java +20 -0
- data/src/toxi/geom/QuadtreeVisitor.java +44 -0
- data/src/toxi/geom/Quaternion.java +641 -0
- data/src/toxi/geom/Ray2D.java +146 -0
- data/src/toxi/geom/Ray3D.java +150 -0
- data/src/toxi/geom/Ray3DIntersector.java +75 -0
- data/src/toxi/geom/ReadonlyVec2D.java +575 -0
- data/src/toxi/geom/ReadonlyVec3D.java +628 -0
- data/src/toxi/geom/ReadonlyVec4D.java +431 -0
- data/src/toxi/geom/Rect.java +720 -0
- data/src/toxi/geom/Reflector3D.java +58 -0
- data/src/toxi/geom/Shape2D.java +94 -0
- data/src/toxi/geom/Shape3D.java +42 -0
- data/src/toxi/geom/SingularMatrixException.java +57 -0
- data/src/toxi/geom/SpatialBins.java +182 -0
- data/src/toxi/geom/SpatialIndex.java +61 -0
- data/src/toxi/geom/Sphere.java +224 -0
- data/src/toxi/geom/SphereIntersectorReflector.java +196 -0
- data/src/toxi/geom/Spline2D.java +349 -0
- data/src/toxi/geom/Spline3D.java +351 -0
- data/src/toxi/geom/SutherlandHodgemanClipper.java +151 -0
- data/src/toxi/geom/Triangle2D.java +422 -0
- data/src/toxi/geom/Triangle3D.java +456 -0
- data/src/toxi/geom/TriangleIntersector.java +105 -0
- data/src/toxi/geom/Vec2D.java +1328 -0
- data/src/toxi/geom/Vec3D.java +1832 -0
- data/src/toxi/geom/Vec4D.java +985 -0
- data/src/toxi/geom/VecMathUtil.java +100 -0
- data/src/toxi/geom/XAxisCylinder.java +64 -0
- data/src/toxi/geom/YAxisCylinder.java +65 -0
- data/src/toxi/geom/ZAxisCylinder.java +64 -0
- data/src/toxi/geom/mesh/BezierPatch.java +200 -0
- data/src/toxi/geom/mesh/BoxSelector.java +62 -0
- data/src/toxi/geom/mesh/DefaultSTLColorModel.java +67 -0
- data/src/toxi/geom/mesh/DefaultSelector.java +50 -0
- data/src/toxi/geom/mesh/Face.java +176 -0
- data/src/toxi/geom/mesh/LaplacianSmooth.java +80 -0
- data/src/toxi/geom/mesh/MaterialiseSTLColorModel.java +150 -0
- data/src/toxi/geom/mesh/Mesh3D.java +224 -0
- data/src/toxi/geom/mesh/MeshIntersector.java +91 -0
- data/src/toxi/geom/mesh/OBJWriter.java +194 -0
- data/src/toxi/geom/mesh/PLYWriter.java +167 -0
- data/src/toxi/geom/mesh/PlaneSelector.java +90 -0
- data/src/toxi/geom/mesh/STLColorModel.java +54 -0
- data/src/toxi/geom/mesh/STLReader.java +185 -0
- data/src/toxi/geom/mesh/STLWriter.java +323 -0
- data/src/toxi/geom/mesh/SphereFunction.java +156 -0
- data/src/toxi/geom/mesh/SphericalHarmonics.java +110 -0
- data/src/toxi/geom/mesh/SuperEllipsoid.java +110 -0
- data/src/toxi/geom/mesh/SurfaceFunction.java +75 -0
- data/src/toxi/geom/mesh/SurfaceMeshBuilder.java +149 -0
- data/src/toxi/geom/mesh/Terrain.java +451 -0
- data/src/toxi/geom/mesh/TriangleMesh.java +1201 -0
- data/src/toxi/geom/mesh/Vertex.java +78 -0
- data/src/toxi/geom/mesh/VertexSelector.java +193 -0
- data/src/toxi/geom/mesh/WEFace.java +100 -0
- data/src/toxi/geom/mesh/WEMeshFilterStrategy.java +51 -0
- data/src/toxi/geom/mesh/WETriangleMesh.java +761 -0
- data/src/toxi/geom/mesh/WEVertex.java +134 -0
- data/src/toxi/geom/mesh/WingedEdge.java +115 -0
- data/src/toxi/geom/mesh/subdiv/CentroidSubdiv.java +37 -0
- data/src/toxi/geom/mesh/subdiv/DisplacementSubdivision.java +85 -0
- data/src/toxi/geom/mesh/subdiv/DualDisplacementSubdivision.java +94 -0
- data/src/toxi/geom/mesh/subdiv/DualSubdivision.java +49 -0
- data/src/toxi/geom/mesh/subdiv/EdgeLengthComparator.java +50 -0
- data/src/toxi/geom/mesh/subdiv/FaceCountComparator.java +51 -0
- data/src/toxi/geom/mesh/subdiv/MidpointDisplacementSubdivision.java +80 -0
- data/src/toxi/geom/mesh/subdiv/MidpointSubdiv.java +42 -0
- data/src/toxi/geom/mesh/subdiv/MidpointSubdivision.java +48 -0
- data/src/toxi/geom/mesh/subdiv/NewSubdivStrategy.java +23 -0
- data/src/toxi/geom/mesh/subdiv/NormalDisplacementSubdivision.java +74 -0
- data/src/toxi/geom/mesh/subdiv/SubdivisionStrategy.java +83 -0
- data/src/toxi/geom/mesh/subdiv/TriSubdivision.java +51 -0
- data/src/toxi/geom/mesh2d/DelaunayTriangle.java +222 -0
- data/src/toxi/geom/mesh2d/DelaunayTriangulation.java +327 -0
- data/src/toxi/geom/mesh2d/DelaunayVertex.java +560 -0
- data/src/toxi/geom/mesh2d/Voronoi.java +149 -0
- data/src/toxi/geom/nurbs/BasicNurbsCurve.java +210 -0
- data/src/toxi/geom/nurbs/BasicNurbsSurface.java +233 -0
- data/src/toxi/geom/nurbs/ControlNet.java +148 -0
- data/src/toxi/geom/nurbs/CurveCreator.java +112 -0
- data/src/toxi/geom/nurbs/CurveUtils.java +259 -0
- data/src/toxi/geom/nurbs/InterpolationException.java +65 -0
- data/src/toxi/geom/nurbs/KnotVector.java +333 -0
- data/src/toxi/geom/nurbs/NurbsCreator.java +815 -0
- data/src/toxi/geom/nurbs/NurbsCurve.java +120 -0
- data/src/toxi/geom/nurbs/NurbsMeshCreator.java +145 -0
- data/src/toxi/geom/nurbs/NurbsSurface.java +147 -0
- data/src/toxi/image/util/Filter8bit.java +331 -0
- data/src/toxi/image/util/TiledFrameExporter.java +162 -0
- data/src/toxi/math/BezierInterpolation.java +102 -0
- data/src/toxi/math/CircularInterpolation.java +88 -0
- data/src/toxi/math/CosineInterpolation.java +51 -0
- data/src/toxi/math/DecimatedInterpolation.java +77 -0
- data/src/toxi/math/ExponentialInterpolation.java +68 -0
- data/src/toxi/math/InterpolateStrategy.java +60 -0
- data/src/toxi/math/Interpolation2D.java +93 -0
- data/src/toxi/math/LinearInterpolation.java +46 -0
- data/src/toxi/math/MathUtils.java +990 -0
- data/src/toxi/math/NonLinearScaleMap.java +101 -0
- data/src/toxi/math/ScaleMap.java +183 -0
- data/src/toxi/math/SigmoidInterpolation.java +78 -0
- data/src/toxi/math/SinCosLUT.java +141 -0
- data/src/toxi/math/ThresholdInterpolation.java +58 -0
- data/src/toxi/math/ZoomLensInterpolation.java +126 -0
- data/src/toxi/math/conversion/UnitTranslator.java +161 -0
- data/src/toxi/math/noise/PerlinNoise.java +281 -0
- data/src/toxi/math/noise/SimplexNoise.java +542 -0
- data/src/toxi/math/waves/AMFMSineWave.java +143 -0
- data/src/toxi/math/waves/AbstractWave.java +248 -0
- data/src/toxi/math/waves/ConstantWave.java +48 -0
- data/src/toxi/math/waves/FMHarmonicSquareWave.java +155 -0
- data/src/toxi/math/waves/FMSawtoothWave.java +144 -0
- data/src/toxi/math/waves/FMSineWave.java +142 -0
- data/src/toxi/math/waves/FMSquareWave.java +143 -0
- data/src/toxi/math/waves/FMTriangleWave.java +126 -0
- data/src/toxi/math/waves/SineWave.java +81 -0
- data/src/toxi/math/waves/Wave2D.java +68 -0
- data/src/toxi/math/waves/WaveState.java +69 -0
- data/src/toxi/music/scale/AbstractScale.java +117 -0
- data/src/toxi/music/scale/GenericScale.java +66 -0
- data/src/toxi/music/scale/MajorScale.java +41 -0
- data/src/toxi/newmesh/AttributedEdge.java +106 -0
- data/src/toxi/newmesh/AttributedFace.java +63 -0
- data/src/toxi/newmesh/IndexedTriangleMesh.java +809 -0
- data/src/toxi/newmesh/MeshAttributeCompiler.java +45 -0
- data/src/toxi/newmesh/MeshFaceNormalCompiler.java +52 -0
- data/src/toxi/newmesh/MeshUVCompiler.java +52 -0
- data/src/toxi/newmesh/MeshVertexColorCompiler.java +49 -0
- data/src/toxi/newmesh/MeshVertexCompiler.java +54 -0
- data/src/toxi/newmesh/MeshVertexNormalCompiler.java +55 -0
- data/src/toxi/newmesh/SpatialIndex.java +78 -0
- data/src/toxi/physics2d/ParticlePath2D.java +100 -0
- data/src/toxi/physics2d/ParticleString2D.java +184 -0
- data/src/toxi/physics2d/PullBackSpring2D.java +51 -0
- data/src/toxi/physics2d/VerletConstrainedSpring2D.java +89 -0
- data/src/toxi/physics2d/VerletMinDistanceSpring2D.java +57 -0
- data/src/toxi/physics2d/VerletParticle2D.java +457 -0
- data/src/toxi/physics2d/VerletPhysics2D.java +448 -0
- data/src/toxi/physics2d/VerletSpring2D.java +181 -0
- data/src/toxi/physics2d/behaviors/AttractionBehavior2D.java +212 -0
- data/src/toxi/physics2d/behaviors/ConstantForceBehavior2D.java +112 -0
- data/src/toxi/physics2d/behaviors/GravityBehavior2D.java +61 -0
- data/src/toxi/physics2d/behaviors/ParticleBehavior2D.java +66 -0
- data/src/toxi/physics2d/constraints/AngularConstraint.java +83 -0
- data/src/toxi/physics2d/constraints/AxisConstraint.java +71 -0
- data/src/toxi/physics2d/constraints/CircularConstraint.java +69 -0
- data/src/toxi/physics2d/constraints/MaxConstraint.java +66 -0
- data/src/toxi/physics2d/constraints/MinConstraint.java +66 -0
- data/src/toxi/physics2d/constraints/ParticleConstraint2D.java +47 -0
- data/src/toxi/physics2d/constraints/PolygonConstraint.java +93 -0
- data/src/toxi/physics2d/constraints/RectConstraint.java +114 -0
- data/src/toxi/physics3d/ParticlePath3D.java +100 -0
- data/src/toxi/physics3d/ParticleString3D.java +184 -0
- data/src/toxi/physics3d/PullBackSpring3D.java +50 -0
- data/src/toxi/physics3d/VerletConstrainedSpring3D.java +88 -0
- data/src/toxi/physics3d/VerletMinDistanceSpring3D.java +56 -0
- data/src/toxi/physics3d/VerletParticle3D.java +385 -0
- data/src/toxi/physics3d/VerletPhysics3D.java +417 -0
- data/src/toxi/physics3d/VerletSpring3D.java +180 -0
- data/src/toxi/physics3d/behaviors/AttractionBehavior3D.java +182 -0
- data/src/toxi/physics3d/behaviors/ConstantForceBehavior3D.java +92 -0
- data/src/toxi/physics3d/behaviors/GravityBehavior3D.java +61 -0
- data/src/toxi/physics3d/behaviors/ParticleBehavior3D.java +52 -0
- data/src/toxi/physics3d/constraints/AxisConstraint.java +68 -0
- data/src/toxi/physics3d/constraints/BoxConstraint.java +121 -0
- data/src/toxi/physics3d/constraints/CylinderConstraint.java +87 -0
- data/src/toxi/physics3d/constraints/MaxConstraint.java +65 -0
- data/src/toxi/physics3d/constraints/MinConstraint.java +65 -0
- data/src/toxi/physics3d/constraints/ParticleConstraint3D.java +49 -0
- data/src/toxi/physics3d/constraints/PlaneConstraint.java +78 -0
- data/src/toxi/physics3d/constraints/SoftBoxConstraint.java +87 -0
- data/src/toxi/physics3d/constraints/SphereConstraint.java +108 -0
- data/src/toxi/processing/ArrowModifier.java +116 -0
- data/src/toxi/processing/DashedLineModifier.java +48 -0
- data/src/toxi/processing/DeltaOrientationMapper.java +57 -0
- data/src/toxi/processing/Line2DRenderModifier.java +18 -0
- data/src/toxi/processing/MeshToVBO.java +94 -0
- data/src/toxi/processing/NormalMapper.java +18 -0
- data/src/toxi/processing/POVInterface.java +121 -0
- data/src/toxi/processing/POVMesh.java +219 -0
- data/src/toxi/processing/POVWriter.java +460 -0
- data/src/toxi/processing/RCOpaque.java +77 -0
- data/src/toxi/processing/RCTransp.java +78 -0
- data/src/toxi/processing/TextureBuilder.java +232 -0
- data/src/toxi/processing/Textures.java +110 -0
- data/src/toxi/processing/ToxiclibsSupport.java +1239 -0
- data/src/toxi/processing/Tracing.java +25 -0
- data/src/toxi/processing/XYZNormalMapper.java +30 -0
- data/src/toxi/sim/automata/CAMatrix.java +297 -0
- data/src/toxi/sim/automata/CARule.java +76 -0
- data/src/toxi/sim/automata/CARule2D.java +354 -0
- data/src/toxi/sim/automata/CAWolfram1D.java +309 -0
- data/src/toxi/sim/automata/EvolvableMatrix.java +61 -0
- data/src/toxi/sim/automata/MatrixEvolver.java +42 -0
- data/src/toxi/sim/dla/BottomUpOrder.java +76 -0
- data/src/toxi/sim/dla/DLA.java +497 -0
- data/src/toxi/sim/dla/DLAConfiguration.java +364 -0
- data/src/toxi/sim/dla/DLAEventAdapter.java +64 -0
- data/src/toxi/sim/dla/DLAEventListener.java +57 -0
- data/src/toxi/sim/dla/DLAGuideLines.java +219 -0
- data/src/toxi/sim/dla/DLAParticle.java +102 -0
- data/src/toxi/sim/dla/DLASegment.java +88 -0
- data/src/toxi/sim/dla/PipelineOrder.java +50 -0
- data/src/toxi/sim/dla/RadialDistanceOrder.java +92 -0
- data/src/toxi/sim/erosion/ErosionFunction.java +122 -0
- data/src/toxi/sim/erosion/TalusAngleErosion.java +145 -0
- data/src/toxi/sim/erosion/ThermalErosion.java +75 -0
- data/src/toxi/sim/fluids/FluidSolver2D.java +762 -0
- data/src/toxi/sim/fluids/FluidSolver3D.java +326 -0
- data/src/toxi/sim/grayscott/GrayScott.java +469 -0
- data/src/toxi/util/DateUtils.java +141 -0
- data/src/toxi/util/FileSequenceDescriptor.java +181 -0
- data/src/toxi/util/FileUtils.java +467 -0
- data/src/toxi/util/datatypes/ArraySet.java +128 -0
- data/src/toxi/util/datatypes/ArrayUtil.java +404 -0
- data/src/toxi/util/datatypes/BiasedDoubleRange.java +141 -0
- data/src/toxi/util/datatypes/BiasedFloatRange.java +141 -0
- data/src/toxi/util/datatypes/BiasedIntegerRange.java +141 -0
- data/src/toxi/util/datatypes/DoubleRange.java +251 -0
- data/src/toxi/util/datatypes/FloatRange.java +251 -0
- data/src/toxi/util/datatypes/GenericSet.java +215 -0
- data/src/toxi/util/datatypes/IntegerRange.java +247 -0
- data/src/toxi/util/datatypes/IntegerSet.java +149 -0
- data/src/toxi/util/datatypes/ItemIndex.java +72 -0
- data/src/toxi/util/datatypes/SingletonRegistry.java +91 -0
- data/src/toxi/util/datatypes/TypedProperties.java +291 -0
- data/src/toxi/util/datatypes/UndirectedGraph.java +134 -0
- data/src/toxi/util/datatypes/UniqueItemIndex.java +223 -0
- data/src/toxi/util/datatypes/WeightedRandomEntry.java +76 -0
- data/src/toxi/util/datatypes/WeightedRandomSet.java +125 -0
- data/src/toxi/util/events/EventDispatcher.java +86 -0
- data/src/toxi/volume/AdditiveBrush.java +19 -0
- data/src/toxi/volume/ArrayIsoSurface.java +297 -0
- data/src/toxi/volume/BoxBrush.java +100 -0
- data/src/toxi/volume/BrushMode.java +16 -0
- data/src/toxi/volume/HashIsoSurface.java +354 -0
- data/src/toxi/volume/IsoSurface.java +59 -0
- data/src/toxi/volume/MarchingCubesIndex.java +312 -0
- data/src/toxi/volume/MeshLatticeBuilder.java +358 -0
- data/src/toxi/volume/MeshVoxelizer.java +216 -0
- data/src/toxi/volume/MultiplyBrush.java +20 -0
- data/src/toxi/volume/PeakBrush.java +21 -0
- data/src/toxi/volume/ReplaceBrush.java +19 -0
- data/src/toxi/volume/RoundBrush.java +113 -0
- data/src/toxi/volume/VolumetricBrush.java +160 -0
- data/src/toxi/volume/VolumetricHashMap.java +179 -0
- data/src/toxi/volume/VolumetricSpace.java +195 -0
- data/src/toxi/volume/VolumetricSpaceArray.java +214 -0
- data/toxiclibs.gemspec +34 -0
- metadata +424 -27
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* __ .__ .__ ._____.
|
|
3
|
+
* _/ |_ _______ __|__| ____ | | |__\_ |__ ______
|
|
4
|
+
* \ __\/ _ \ \/ / |/ ___\| | | || __ \ / ___/
|
|
5
|
+
* | | ( <_> > <| \ \___| |_| || \_\ \\___ \
|
|
6
|
+
* |__| \____/__/\_ \__|\___ >____/__||___ /____ >
|
|
7
|
+
* \/ \/ \/ \/
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2006-2011 Karsten Schmidt
|
|
10
|
+
*
|
|
11
|
+
* This library is free software; you can redistribute it and/or
|
|
12
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
13
|
+
* License as published by the Free Software Foundation; either
|
|
14
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* http://creativecommons.org/licenses/LGPL/2.1/
|
|
17
|
+
*
|
|
18
|
+
* This library is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21
|
+
* Lesser General Public License for more details.
|
|
22
|
+
*
|
|
23
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
24
|
+
* License along with this library; if not, write to the Free Software
|
|
25
|
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
package toxi.geom;
|
|
29
|
+
|
|
30
|
+
import javax.xml.bind.annotation.XmlAccessType;
|
|
31
|
+
import javax.xml.bind.annotation.XmlAccessorType;
|
|
32
|
+
import javax.xml.bind.annotation.XmlElement;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A simple 2D ray datatype
|
|
36
|
+
*/
|
|
37
|
+
@XmlAccessorType(XmlAccessType.FIELD)
|
|
38
|
+
public class Ray2D extends Vec2D {
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
@XmlElement(required = true)
|
|
44
|
+
protected Vec2D dir;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
public Ray2D() {
|
|
50
|
+
super();
|
|
51
|
+
dir = Vec2D.Y_AXIS.copy();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param x
|
|
57
|
+
* @param y
|
|
58
|
+
* @param d
|
|
59
|
+
*/
|
|
60
|
+
public Ray2D(float x, float y, ReadonlyVec2D d) {
|
|
61
|
+
super(x, y);
|
|
62
|
+
dir = d.getNormalized();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @param o
|
|
68
|
+
* @param d
|
|
69
|
+
*/
|
|
70
|
+
public Ray2D(ReadonlyVec2D o, ReadonlyVec2D d) {
|
|
71
|
+
this(o.x(), o.y(), d);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns a copy of the ray's direction vector.
|
|
76
|
+
*
|
|
77
|
+
* @return vector
|
|
78
|
+
*/
|
|
79
|
+
public Vec2D getDirection() {
|
|
80
|
+
return dir.copy();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Calculates the distance between the given point and the infinite line
|
|
85
|
+
* coinciding with this ray.
|
|
86
|
+
*
|
|
87
|
+
* @param p
|
|
88
|
+
* @return distance
|
|
89
|
+
*/
|
|
90
|
+
public float getDistanceToPoint(Vec2D p) {
|
|
91
|
+
Vec2D sp = p.sub(this);
|
|
92
|
+
return sp.distanceTo(dir.scale(sp.dot(dir)));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param dist
|
|
98
|
+
* @return
|
|
99
|
+
*/
|
|
100
|
+
public Vec2D getPointAtDistance(float dist) {
|
|
101
|
+
return add(dir.scale(dist));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Uses a normalized copy of the given vector as the ray direction.
|
|
106
|
+
*
|
|
107
|
+
* @param d
|
|
108
|
+
* new direction
|
|
109
|
+
* @return itself
|
|
110
|
+
*/
|
|
111
|
+
public Ray2D setDirection(ReadonlyVec2D d) {
|
|
112
|
+
dir.set(d).normalize();
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @param d
|
|
119
|
+
* @return
|
|
120
|
+
*/
|
|
121
|
+
public Ray2D setNormalizedDirection(ReadonlyVec2D d) {
|
|
122
|
+
dir.set(d);
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Converts the ray into a 2D Line segment with its start point coinciding
|
|
128
|
+
* with the ray origin and its other end point at the given distance along
|
|
129
|
+
* the ray.
|
|
130
|
+
*
|
|
131
|
+
* @param dist
|
|
132
|
+
* end point distance
|
|
133
|
+
* @return line segment
|
|
134
|
+
*/
|
|
135
|
+
public Line2D toLine2DWithPointAtDistance(float dist) {
|
|
136
|
+
return new Line2D(this, getPointAtDistance(dist));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @return
|
|
142
|
+
*/
|
|
143
|
+
public String toString() {
|
|
144
|
+
return "origin: " + super.toString() + " dir: " + dir;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* __ .__ .__ ._____.
|
|
3
|
+
* _/ |_ _______ __|__| ____ | | |__\_ |__ ______
|
|
4
|
+
* \ __\/ _ \ \/ / |/ ___\| | | || __ \ / ___/
|
|
5
|
+
* | | ( <_> > <| \ \___| |_| || \_\ \\___ \
|
|
6
|
+
* |__| \____/__/\_ \__|\___ >____/__||___ /____ >
|
|
7
|
+
* \/ \/ \/ \/
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2006-2011 Karsten Schmidt
|
|
10
|
+
*
|
|
11
|
+
* This library is free software; you can redistribute it and/or
|
|
12
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
13
|
+
* License as published by the Free Software Foundation; either
|
|
14
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* http://creativecommons.org/licenses/LGPL/2.1/
|
|
17
|
+
*
|
|
18
|
+
* This library is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21
|
+
* Lesser General Public License for more details.
|
|
22
|
+
*
|
|
23
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
24
|
+
* License along with this library; if not, write to the Free Software
|
|
25
|
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
package toxi.geom;
|
|
29
|
+
|
|
30
|
+
import javax.xml.bind.annotation.XmlAccessType;
|
|
31
|
+
import javax.xml.bind.annotation.XmlAccessorType;
|
|
32
|
+
import javax.xml.bind.annotation.XmlElement;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A simple 3D ray datatype
|
|
36
|
+
*/
|
|
37
|
+
@XmlAccessorType(XmlAccessType.FIELD)
|
|
38
|
+
public class Ray3D extends Vec3D {
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
@XmlElement(required = true)
|
|
44
|
+
protected Vec3D dir;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
public Ray3D() {
|
|
50
|
+
super();
|
|
51
|
+
dir = Vec3D.Y_AXIS.copy();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param x
|
|
57
|
+
* @param y
|
|
58
|
+
* @param z
|
|
59
|
+
* @param d
|
|
60
|
+
*/
|
|
61
|
+
public Ray3D(float x, float y, float z, ReadonlyVec3D d) {
|
|
62
|
+
super(x, y, z);
|
|
63
|
+
dir = d.getNormalized();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param o
|
|
69
|
+
* @param d
|
|
70
|
+
*/
|
|
71
|
+
public Ray3D(ReadonlyVec3D o, ReadonlyVec3D d) {
|
|
72
|
+
this(o.x(), o.y(), o.z(), d);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns a copy of the ray's direction vector.
|
|
77
|
+
*
|
|
78
|
+
* @return vector
|
|
79
|
+
*/
|
|
80
|
+
public Vec3D getDirection() {
|
|
81
|
+
return dir.copy();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Calculates the distance between the given point and the infinite line
|
|
86
|
+
* coinciding with this ray.
|
|
87
|
+
*
|
|
88
|
+
* @param p
|
|
89
|
+
* @return distance
|
|
90
|
+
*/
|
|
91
|
+
public float getDistanceToPoint(Vec3D p) {
|
|
92
|
+
Vec3D sp = p.sub(this);
|
|
93
|
+
return sp.distanceTo(dir.scale(sp.dot(dir)));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns the point at the given distance on the ray. The distance can be
|
|
98
|
+
* any real number.
|
|
99
|
+
*
|
|
100
|
+
* @param dist
|
|
101
|
+
* @return vector
|
|
102
|
+
*/
|
|
103
|
+
public Vec3D getPointAtDistance(float dist) {
|
|
104
|
+
return add(dir.scale(dist));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Uses a normalized copy of the given vector as the ray direction.
|
|
109
|
+
*
|
|
110
|
+
* @param d
|
|
111
|
+
* new direction
|
|
112
|
+
* @return itself
|
|
113
|
+
*/
|
|
114
|
+
public Ray3D setDirection(ReadonlyVec3D d) {
|
|
115
|
+
dir.set(d).normalize();
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @param d
|
|
122
|
+
* @return
|
|
123
|
+
*/
|
|
124
|
+
public Ray3D setNormalizedDirection(ReadonlyVec3D d) {
|
|
125
|
+
dir.set(d);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Converts the ray into a 3D Line segment with its start point coinciding
|
|
131
|
+
* with the ray origin and its other end point at the given distance along
|
|
132
|
+
* the ray.
|
|
133
|
+
*
|
|
134
|
+
* @param dist
|
|
135
|
+
* end point distance
|
|
136
|
+
* @return line segment
|
|
137
|
+
*/
|
|
138
|
+
public Line3D toLine3DWithPointAtDistance(float dist) {
|
|
139
|
+
return new Line3D(this, getPointAtDistance(dist));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @return
|
|
145
|
+
*/
|
|
146
|
+
@Override
|
|
147
|
+
public String toString() {
|
|
148
|
+
return "origin: " + super.toString() + " dir: " + dir;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* __ .__ .__ ._____.
|
|
3
|
+
* _/ |_ _______ __|__| ____ | | |__\_ |__ ______
|
|
4
|
+
* \ __\/ _ \ \/ / |/ ___\| | | || __ \ / ___/
|
|
5
|
+
* | | ( <_> > <| \ \___| |_| || \_\ \\___ \
|
|
6
|
+
* |__| \____/__/\_ \__|\___ >____/__||___ /____ >
|
|
7
|
+
* \/ \/ \/ \/
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2006-2011 Karsten Schmidt
|
|
10
|
+
*
|
|
11
|
+
* This library is free software; you can redistribute it and/or
|
|
12
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
13
|
+
* License as published by the Free Software Foundation; either
|
|
14
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* http://creativecommons.org/licenses/LGPL/2.1/
|
|
17
|
+
*
|
|
18
|
+
* This library is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21
|
+
* Lesser General Public License for more details.
|
|
22
|
+
*
|
|
23
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
24
|
+
* License along with this library; if not, write to the Free Software
|
|
25
|
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
package toxi.geom;
|
|
29
|
+
|
|
30
|
+
import toxi.math.MathUtils;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @author tux
|
|
35
|
+
*/
|
|
36
|
+
public class Ray3DIntersector implements Intersector3D {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
public Ray3D ray;
|
|
42
|
+
private IsectData3D isec;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param ray
|
|
47
|
+
*/
|
|
48
|
+
public Ray3DIntersector(Ray3D ray) {
|
|
49
|
+
this.ray = ray;
|
|
50
|
+
isec = new IsectData3D();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public IsectData3D getIntersectionData() {
|
|
54
|
+
return isec;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public boolean intersectsRay(Ray3D other) {
|
|
58
|
+
Vec3D n = ray.dir.cross(other.dir);
|
|
59
|
+
Vec3D sr = ray.sub(other);
|
|
60
|
+
float absX = MathUtils.abs(n.x);
|
|
61
|
+
float absY = MathUtils.abs(n.y);
|
|
62
|
+
float absZ = MathUtils.abs(n.z);
|
|
63
|
+
float t;
|
|
64
|
+
if (absZ > absX && absZ > absY) {
|
|
65
|
+
t = (sr.x * other.dir.y - sr.y * other.dir.x) / n.z;
|
|
66
|
+
} else if (absX > absY) {
|
|
67
|
+
t = (sr.y * other.dir.z - sr.z * other.dir.y) / n.x;
|
|
68
|
+
} else {
|
|
69
|
+
t = (sr.z * other.dir.x - sr.x * other.dir.z) / n.y;
|
|
70
|
+
}
|
|
71
|
+
isec.isIntersection = (t <= MathUtils.EPS && !Float.isInfinite(t));
|
|
72
|
+
isec.pos = ray.getPointAtDistance(-t);
|
|
73
|
+
return isec.isIntersection;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* __ .__ .__ ._____.
|
|
3
|
+
* _/ |_ _______ __|__| ____ | | |__\_ |__ ______
|
|
4
|
+
* \ __\/ _ \ \/ / |/ ___\| | | || __ \ / ___/
|
|
5
|
+
* | | ( <_> > <| \ \___| |_| || \_\ \\___ \
|
|
6
|
+
* |__| \____/__/\_ \__|\___ >____/__||___ /____ >
|
|
7
|
+
* \/ \/ \/ \/
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2006-2011 Karsten Schmidt
|
|
10
|
+
*
|
|
11
|
+
* This library is free software; you can redistribute it and/or
|
|
12
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
13
|
+
* License as published by the Free Software Foundation; either
|
|
14
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* http://creativecommons.org/licenses/LGPL/2.1/
|
|
17
|
+
*
|
|
18
|
+
* This library is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21
|
+
* Lesser General Public License for more details.
|
|
22
|
+
*
|
|
23
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
24
|
+
* License along with this library; if not, write to the Free Software
|
|
25
|
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
package toxi.geom;
|
|
29
|
+
|
|
30
|
+
import toxi.geom.Vec2D.Axis;
|
|
31
|
+
import toxi.math.InterpolateStrategy;
|
|
32
|
+
import toxi.math.MathUtils;
|
|
33
|
+
import toxi.math.ScaleMap;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Readonly, immutable interface wrapper for Vec2D instances. Used throughout
|
|
37
|
+
* the library for safety purposes.
|
|
38
|
+
*/
|
|
39
|
+
public interface ReadonlyVec2D {
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Adds vector {a,b,c} and returns result as new vector.
|
|
43
|
+
*
|
|
44
|
+
* @param a
|
|
45
|
+
* X coordinate
|
|
46
|
+
* @param b
|
|
47
|
+
* Y coordinate
|
|
48
|
+
* @return result as new vector
|
|
49
|
+
*/
|
|
50
|
+
public Vec2D add(float a, float b);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Add vector v and returns result as new vector.
|
|
54
|
+
*
|
|
55
|
+
* @param v
|
|
56
|
+
* vector to add
|
|
57
|
+
* @return result as new vector
|
|
58
|
+
*/
|
|
59
|
+
public Vec2D add(ReadonlyVec2D v);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Computes the angle between this vector and vector V. This function
|
|
63
|
+
* assumes both vectors are normalized, if this can't be guaranteed, use the
|
|
64
|
+
* alternative implementation {@link #angleBetween(ReadonlyVec2D, boolean)}
|
|
65
|
+
*
|
|
66
|
+
* @param v
|
|
67
|
+
* vector
|
|
68
|
+
* @return angle in radians, or NaN if vectors are parallel
|
|
69
|
+
*/
|
|
70
|
+
public float angleBetween(ReadonlyVec2D v);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Computes the angle between this vector and vector V
|
|
74
|
+
*
|
|
75
|
+
* @param v
|
|
76
|
+
* vector
|
|
77
|
+
* @param forceNormalize
|
|
78
|
+
* true, if normalized versions of the vectors are to be used
|
|
79
|
+
* (Note: only copies will be used, original vectors will not be
|
|
80
|
+
* altered by this method)
|
|
81
|
+
* @return angle in radians, or NaN if vectors are parallel
|
|
82
|
+
*/
|
|
83
|
+
public float angleBetween(ReadonlyVec2D v, boolean forceNormalize);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Computes the perpendicular bisector of two points.
|
|
87
|
+
*
|
|
88
|
+
* @param p
|
|
89
|
+
* other point
|
|
90
|
+
* @return bisector coefficients as {@link Vec3D}
|
|
91
|
+
*/
|
|
92
|
+
public Vec3D bisect(Vec2D p);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Compares the length of the vector with another one.
|
|
96
|
+
*
|
|
97
|
+
* @param v
|
|
98
|
+
* vector to compare with
|
|
99
|
+
* @return -1 if other vector is longer, 0 if both are equal or else +1
|
|
100
|
+
*/
|
|
101
|
+
public int compareTo(ReadonlyVec2D v);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @return a new independent instance/copy of a given vector
|
|
105
|
+
*/
|
|
106
|
+
public Vec2D copy();
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Calculates the cross-product with the given vector.
|
|
110
|
+
*
|
|
111
|
+
* @param v
|
|
112
|
+
* vector
|
|
113
|
+
* @return the magnitude of the vector that would result from a regular 3D
|
|
114
|
+
* cross product of the input vectors, taking their Z values
|
|
115
|
+
* implicitly as 0 (i.e. treating the 2D space as a plane in the 3D
|
|
116
|
+
* space). The 3D cross product will be perpendicular to that plane,
|
|
117
|
+
* and thus have 0 X & Y components (thus the scalar returned is the
|
|
118
|
+
* Z value of the 3D cross product vector).
|
|
119
|
+
* @see <a href="http://stackoverflow.com/questions/243945/">Stackoverflow
|
|
120
|
+
* entry</a>
|
|
121
|
+
*/
|
|
122
|
+
public float cross(ReadonlyVec2D v);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Calculates distance to another vector
|
|
126
|
+
*
|
|
127
|
+
* @param v
|
|
128
|
+
* non-null vector
|
|
129
|
+
* @return distance or Float.NaN if v=null
|
|
130
|
+
*/
|
|
131
|
+
public float distanceTo(ReadonlyVec2D v);
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Calculates the squared distance to another vector
|
|
135
|
+
*
|
|
136
|
+
* @see #magSquared()
|
|
137
|
+
* @param v
|
|
138
|
+
* non-null vector
|
|
139
|
+
* @return distance or NaN if v=null
|
|
140
|
+
*/
|
|
141
|
+
public float distanceToSquared(ReadonlyVec2D v);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Computes the scalar product (dot product) with the given vector.
|
|
145
|
+
*
|
|
146
|
+
* @see <a href="http://en.wikipedia.org/wiki/Dot_product">Wikipedia entry</a>
|
|
147
|
+
*
|
|
148
|
+
* @param v
|
|
149
|
+
* @return dot product
|
|
150
|
+
*/
|
|
151
|
+
public float dot(ReadonlyVec2D v);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
*
|
|
155
|
+
* @param obj
|
|
156
|
+
* @return
|
|
157
|
+
*/
|
|
158
|
+
@Override
|
|
159
|
+
public boolean equals(Object obj);
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Compares this vector with the one given. The vectors are deemed equal if
|
|
163
|
+
* the individual differences of all component values are within the given
|
|
164
|
+
* tolerance.
|
|
165
|
+
*
|
|
166
|
+
* @param v
|
|
167
|
+
* the v
|
|
168
|
+
* @param tolerance
|
|
169
|
+
* the tolerance
|
|
170
|
+
*
|
|
171
|
+
* @return true, if equal
|
|
172
|
+
*/
|
|
173
|
+
public boolean equalsWithTolerance(ReadonlyVec2D v, float tolerance);
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
* @return
|
|
178
|
+
*/
|
|
179
|
+
public Vec2D getAbs();
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Converts the vector from polar to Cartesian space. Assumes this order:
|
|
183
|
+
* x=radius, y=theta
|
|
184
|
+
*
|
|
185
|
+
* @return new vector
|
|
186
|
+
*/
|
|
187
|
+
public Vec2D getCartesian();
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
*
|
|
191
|
+
* @param id
|
|
192
|
+
* @return
|
|
193
|
+
*/
|
|
194
|
+
public float getComponent(Axis id);
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
* @param id
|
|
199
|
+
* @return
|
|
200
|
+
*/
|
|
201
|
+
public float getComponent(int id);
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Creates a copy of the vector which forcefully fits in the given
|
|
205
|
+
* rectangle.
|
|
206
|
+
*
|
|
207
|
+
* @param r
|
|
208
|
+
* @return fitted vector
|
|
209
|
+
*/
|
|
210
|
+
public Vec2D getConstrained(Rect r);
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Creates a new vector whose components are the integer value of their
|
|
214
|
+
* current values
|
|
215
|
+
*
|
|
216
|
+
* @return result as new vector
|
|
217
|
+
*/
|
|
218
|
+
public Vec2D getFloored();
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Creates a new vector whose components are the fractional part of their
|
|
222
|
+
* current values
|
|
223
|
+
*
|
|
224
|
+
* @return result as new vector
|
|
225
|
+
*/
|
|
226
|
+
public Vec2D getFrac();
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Scales vector uniformly by factor -1 ( v = -v )
|
|
230
|
+
*
|
|
231
|
+
* @return result as new vector
|
|
232
|
+
*/
|
|
233
|
+
public Vec2D getInverted();
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Creates a copy of the vector with its magnitude limited to the length
|
|
237
|
+
* given
|
|
238
|
+
*
|
|
239
|
+
* @param lim
|
|
240
|
+
* new maximum magnitude
|
|
241
|
+
* @return result as new vector
|
|
242
|
+
*/
|
|
243
|
+
public Vec2D getLimited(float lim);
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Produces a new vector with its coordinates passed through the given
|
|
247
|
+
* {@link ScaleMap}.
|
|
248
|
+
*
|
|
249
|
+
* @param map
|
|
250
|
+
* @return mapped vector
|
|
251
|
+
*/
|
|
252
|
+
public Vec2D getMapped(ScaleMap map);
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Produces the normalized version as a new vector
|
|
256
|
+
*
|
|
257
|
+
* @return new vector
|
|
258
|
+
*/
|
|
259
|
+
public Vec2D getNormalized();
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Produces a new vector normalized to the given length.
|
|
263
|
+
*
|
|
264
|
+
* @param len
|
|
265
|
+
* new desired length
|
|
266
|
+
*
|
|
267
|
+
* @return new vector
|
|
268
|
+
*/
|
|
269
|
+
public Vec2D getNormalizedTo(float len);
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
*
|
|
273
|
+
* @return
|
|
274
|
+
*/
|
|
275
|
+
public Vec2D getPerpendicular();
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Converts the current vector into polar coordinates. After the conversion
|
|
279
|
+
* the x component of the vector contains the radius (magnitude) and y the
|
|
280
|
+
* rotation angle.
|
|
281
|
+
*
|
|
282
|
+
* @return new vector
|
|
283
|
+
*/
|
|
284
|
+
public Vec2D getPolar();
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @return
|
|
289
|
+
*/
|
|
290
|
+
public Vec2D getReciprocal();
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
*
|
|
294
|
+
* @param normal
|
|
295
|
+
* @return
|
|
296
|
+
*/
|
|
297
|
+
public Vec2D getReflected(ReadonlyVec2D normal);
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Creates a new vector rotated by the given angle around the Z axis.
|
|
301
|
+
*
|
|
302
|
+
* @param theta
|
|
303
|
+
* @return rotated vector
|
|
304
|
+
*/
|
|
305
|
+
public Vec2D getRotated(float theta);
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Creates a new vector with its coordinates rounded to the given precision
|
|
309
|
+
* (grid alignment).
|
|
310
|
+
*
|
|
311
|
+
* @param prec
|
|
312
|
+
* @return grid aligned vector
|
|
313
|
+
*/
|
|
314
|
+
public Vec2D getRoundedTo(float prec);
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Creates a new vector in which all components are replaced with the signum
|
|
318
|
+
* of their original values. In other words if a components value was
|
|
319
|
+
* negative its new value will be -1, if zero => 0, if positive => +1
|
|
320
|
+
*
|
|
321
|
+
* @return result vector
|
|
322
|
+
*/
|
|
323
|
+
public Vec2D getSignum();
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Computes the vector's direction in the XY plane (for example for 2D
|
|
327
|
+
* points). The positive X axis equals 0 degrees.
|
|
328
|
+
*
|
|
329
|
+
* @return rotation angle
|
|
330
|
+
*/
|
|
331
|
+
public float heading();
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Interpolates the vector towards the given target vector, using linear
|
|
335
|
+
* interpolation
|
|
336
|
+
*
|
|
337
|
+
* @param v
|
|
338
|
+
* target vector
|
|
339
|
+
* @param f
|
|
340
|
+
* interpolation factor (should be in the range 0..1)
|
|
341
|
+
* @return result as new vector
|
|
342
|
+
*/
|
|
343
|
+
public Vec2D interpolateTo(ReadonlyVec2D v, float f);
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Interpolates the vector towards the given target vector, using the given
|
|
347
|
+
* {@link InterpolateStrategy}
|
|
348
|
+
*
|
|
349
|
+
* @param v
|
|
350
|
+
* target vector
|
|
351
|
+
* @param f
|
|
352
|
+
* interpolation factor (should be in the range 0..1)
|
|
353
|
+
* @param s
|
|
354
|
+
* InterpolateStrategy instance
|
|
355
|
+
* @return result as new vector
|
|
356
|
+
*/
|
|
357
|
+
public Vec2D interpolateTo(ReadonlyVec2D v, float f, InterpolateStrategy s);
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Checks if the point is inside the given sphere.
|
|
361
|
+
*
|
|
362
|
+
* @param sO
|
|
363
|
+
* circle origin/centre
|
|
364
|
+
* @param sR
|
|
365
|
+
* circle radius
|
|
366
|
+
* @return true, if point is in sphere
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
public boolean isInCircle(ReadonlyVec2D sO, float sR);
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Checks if the point is inside the given rectangle.
|
|
373
|
+
*
|
|
374
|
+
* @param r
|
|
375
|
+
* bounding rectangle
|
|
376
|
+
* @return true, if point is inside
|
|
377
|
+
*/
|
|
378
|
+
public boolean isInRectangle(Rect r);
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Checks if point vector is inside the triangle created by the points a, b
|
|
382
|
+
* and c. These points will create a plane and the point checked will have
|
|
383
|
+
* to be on this plane in the region between a,b,c.
|
|
384
|
+
*
|
|
385
|
+
* Note: The triangle must be defined in clockwise order a,b,c
|
|
386
|
+
*
|
|
387
|
+
* @param a
|
|
388
|
+
* @param b
|
|
389
|
+
* @param c
|
|
390
|
+
* @return true, if point is in triangle.
|
|
391
|
+
*/
|
|
392
|
+
public boolean isInTriangle(Vec2D a, Vec2D b, Vec2D c);
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Checks if the vector is parallel with either the X or Y axis (any
|
|
396
|
+
* direction).
|
|
397
|
+
*
|
|
398
|
+
* @param tolerance
|
|
399
|
+
* @return true, if parallel within the given tolerance
|
|
400
|
+
*/
|
|
401
|
+
public boolean isMajorAxis(float tolerance);
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Checks if vector has a magnitude equals or close to zero (tolerance used
|
|
405
|
+
* is {@link MathUtils#EPS}).
|
|
406
|
+
*
|
|
407
|
+
* @return true, if zero vector
|
|
408
|
+
*/
|
|
409
|
+
public boolean isZeroVector();
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Calculates the magnitude/eucledian length of the vector
|
|
413
|
+
*
|
|
414
|
+
* @return vector length
|
|
415
|
+
*/
|
|
416
|
+
public float magnitude();
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Calculates only the squared magnitude/length of the vector. Useful for
|
|
420
|
+
* inverse square law applications and/or for speed reasons or if the real
|
|
421
|
+
* eucledian distance is not required (e.g. sorting).
|
|
422
|
+
*
|
|
423
|
+
* Please note the vector should contain cartesian (not polar) coordinates
|
|
424
|
+
* in order for this function to work. The magnitude of polar vectors is
|
|
425
|
+
* stored in the x component.
|
|
426
|
+
*
|
|
427
|
+
* @return squared magnitude (x^2 + y^2)
|
|
428
|
+
*/
|
|
429
|
+
public float magSquared();
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Constructs a new vector consisting of the largest components of both
|
|
433
|
+
* vectors.
|
|
434
|
+
*
|
|
435
|
+
* @param v
|
|
436
|
+
* @return result as new vector
|
|
437
|
+
*/
|
|
438
|
+
public Vec2D max(ReadonlyVec2D v);
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Constructs a new vector consisting of the smallest components of both
|
|
442
|
+
* vectors.
|
|
443
|
+
*
|
|
444
|
+
* @param v
|
|
445
|
+
* comparing vector
|
|
446
|
+
* @return result as new vector
|
|
447
|
+
*/
|
|
448
|
+
public Vec2D min(ReadonlyVec2D v);
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Scales vector uniformly and returns result as new vector.
|
|
452
|
+
*
|
|
453
|
+
* @param s
|
|
454
|
+
* scale factor
|
|
455
|
+
* @return new vector
|
|
456
|
+
*/
|
|
457
|
+
public Vec2D scale(float s);
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Scales vector non-uniformly and returns result as new vector.
|
|
461
|
+
*
|
|
462
|
+
* @param a
|
|
463
|
+
* scale factor for X coordinate
|
|
464
|
+
* @param b
|
|
465
|
+
* scale factor for Y coordinate
|
|
466
|
+
* @return new vector
|
|
467
|
+
*/
|
|
468
|
+
public Vec2D scale(float a, float b);
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
*
|
|
472
|
+
* @param s
|
|
473
|
+
* @return
|
|
474
|
+
*/
|
|
475
|
+
public Vec2D scale(ReadonlyVec2D s);
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Scales vector non-uniformly by vector v and returns result as new vector
|
|
479
|
+
*
|
|
480
|
+
* @param s
|
|
481
|
+
* scale vector
|
|
482
|
+
* @return new vector
|
|
483
|
+
*/
|
|
484
|
+
public Vec2D scale(Vec2D s);
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Subtracts vector {a,b,c} and returns result as new vector.
|
|
488
|
+
*
|
|
489
|
+
* @param a
|
|
490
|
+
* X coordinate
|
|
491
|
+
* @param b
|
|
492
|
+
* Y coordinate
|
|
493
|
+
* @return result as new vector
|
|
494
|
+
*/
|
|
495
|
+
public Vec2D sub(float a, float b);
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
*
|
|
499
|
+
* @param v
|
|
500
|
+
* @return
|
|
501
|
+
*/
|
|
502
|
+
public Vec2D sub(ReadonlyVec2D v);
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Subtracts vector v and returns result as new vector.
|
|
506
|
+
*
|
|
507
|
+
* @param v
|
|
508
|
+
* vector to be subtracted
|
|
509
|
+
* @return result as new vector
|
|
510
|
+
*/
|
|
511
|
+
public Vec2D sub(Vec2D v);
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Calculates the normal vector on the given ellipse in the direction of the
|
|
515
|
+
* current point.
|
|
516
|
+
*
|
|
517
|
+
* @param eO
|
|
518
|
+
* ellipse origin/centre
|
|
519
|
+
* @param eR
|
|
520
|
+
* ellipse radii
|
|
521
|
+
* @return a unit normal vector to the tangent plane of the ellipsoid in the
|
|
522
|
+
* point.
|
|
523
|
+
*/
|
|
524
|
+
|
|
525
|
+
public Vec2D tangentNormalOfEllipse(Vec2D eO, Vec2D eR);
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Creates a 3D version of this vector in the XY plane.
|
|
529
|
+
*
|
|
530
|
+
* @return 3D vector
|
|
531
|
+
*/
|
|
532
|
+
public Vec3D to3DXY();
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Creates a 3D version of this vector in the XZ plane. (The 2D Y coordinate
|
|
536
|
+
* interpreted as Z)
|
|
537
|
+
*
|
|
538
|
+
* @return 3D vector
|
|
539
|
+
*/
|
|
540
|
+
public Vec3D to3DXZ();
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Creates a 3D version of this vector in the YZ plane. (The 2D X coordinate
|
|
544
|
+
* interpreted as Y & 2D Y as Z)
|
|
545
|
+
*
|
|
546
|
+
* @return 3D vector
|
|
547
|
+
*/
|
|
548
|
+
public Vec3D to3DYZ();
|
|
549
|
+
|
|
550
|
+
/*
|
|
551
|
+
* (non-Javadoc)
|
|
552
|
+
*
|
|
553
|
+
* @see toxi.geom.DimensionalVector#toArray()
|
|
554
|
+
*/
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
*
|
|
558
|
+
* @return
|
|
559
|
+
*/
|
|
560
|
+
|
|
561
|
+
public float[] toArray();
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
*
|
|
565
|
+
* @return
|
|
566
|
+
*/
|
|
567
|
+
public float x();
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
*
|
|
571
|
+
* @return
|
|
572
|
+
*/
|
|
573
|
+
public float y();
|
|
574
|
+
|
|
575
|
+
}
|