diff --git a/lib/teilchen.jar b/lib/teilchen.jar index f01b969..f507d4e 100644 Binary files a/lib/teilchen.jar and b/lib/teilchen.jar differ diff --git a/processing-library/teilchen/examples/Lesson00_Particle/Lesson00_Particle.pde b/processing-library/teilchen/examples/Lesson00_Particle/Lesson00_Particle.pde index 3fafa9b..ce55ebd 100644 --- a/processing-library/teilchen/examples/Lesson00_Particle/Lesson00_Particle.pde +++ b/processing-library/teilchen/examples/Lesson00_Particle/Lesson00_Particle.pde @@ -8,7 +8,7 @@ import teilchen.util.*; /* - * this sketch show how to create a particle system with a single particle in it. + * this sketch demonstrates how to create a particle system with a single particle in it. */ Physics mPhysics; Particle mParticle; diff --git a/processing-library/teilchen/examples/Lesson01_Gravity/Lesson01_Gravity.pde b/processing-library/teilchen/examples/Lesson01_Gravity/Lesson01_Gravity.pde index 92b98a9..2e26836 100644 --- a/processing-library/teilchen/examples/Lesson01_Gravity/Lesson01_Gravity.pde +++ b/processing-library/teilchen/examples/Lesson01_Gravity/Lesson01_Gravity.pde @@ -8,7 +8,8 @@ import teilchen.util.*; /* - * this sketch show how to create a particle system with a single particle in it. + * this sketch demonstrates how to create a particle system with a single particle in it and a + * gravity force pulling it downward. */ Physics mPhysics; Particle mParticle; diff --git a/processing-library/teilchen/examples/Lesson02_Particles/Lesson02_Particles.pde b/processing-library/teilchen/examples/Lesson02_Particles/Lesson02_Particles.pde index a7bc4d0..944991f 100644 --- a/processing-library/teilchen/examples/Lesson02_Particles/Lesson02_Particles.pde +++ b/processing-library/teilchen/examples/Lesson02_Particles/Lesson02_Particles.pde @@ -8,8 +8,8 @@ import teilchen.util.*; /* - * this sketch shows how to create and handle multiple particles and remove - * individual particles. + * this sketch demonstrates how to create and handle multiple particles and remove individual + * particles. */ Physics mPhysics; void settings() { @@ -39,7 +39,7 @@ void draw() { for (int i = 0; i < mPhysics.particles().size(); i++) { Particle mParticle = mPhysics.particles(i); if (mParticle.position().y > height * 0.9f) { - mPhysics.particles().remove(i); + mPhysics.particles().remove(i); // @TODO(check if this potentially creates an exception) } } /* draw all the particles in the system */ diff --git a/processing-library/teilchen/examples/Lesson03_Attractors/Lesson03_Attractors.pde b/processing-library/teilchen/examples/Lesson03_Attractors/Lesson03_Attractors.pde index 3627f96..ab30cdf 100644 --- a/processing-library/teilchen/examples/Lesson03_Attractors/Lesson03_Attractors.pde +++ b/processing-library/teilchen/examples/Lesson03_Attractors/Lesson03_Attractors.pde @@ -8,7 +8,7 @@ import teilchen.util.*; /* - * this sketch shows how to create and use attractors. + * this sketch demonstrates how to create and use an `Attractor` and how to teleport particles. */ Physics mPhysics; Attractor mAttractor; diff --git a/processing-library/teilchen/examples/Lesson05_Spring/Lesson05_Spring.pde b/processing-library/teilchen/examples/Lesson04_Spring/Lesson04_Spring.pde similarity index 85% rename from processing-library/teilchen/examples/Lesson05_Spring/Lesson05_Spring.pde rename to processing-library/teilchen/examples/Lesson04_Spring/Lesson04_Spring.pde index cc1c327..5ff8e87 100644 --- a/processing-library/teilchen/examples/Lesson05_Spring/Lesson05_Spring.pde +++ b/processing-library/teilchen/examples/Lesson04_Spring/Lesson04_Spring.pde @@ -8,8 +8,8 @@ import teilchen.util.*; /* - * this sketch shows 1 how to create a viscous drag to slow motion eventually - * down. 2 how to create a spring that connects two particles. + * this sketch demonstrates how to create a `Spring` that connects two particles. it also + * demonstrates how to create a `ViscousDrag` to slow down particle motion over time. */ Physics mPhysics; Spring mSpring; @@ -24,9 +24,9 @@ void setup() { mPhysics.add(myDrag); /* create two particles that we can connect with a spring */ Particle myA = mPhysics.makeParticle(); - myA.position().set(width / 2 - 50, height / 2); + myA.position().set(width / 2 - 50, height / 2.0f); Particle myB = mPhysics.makeParticle(); - myB.position().set(width / 2 + 50, height / 2); + myB.position().set(width / 2 + 50, height / 2.0f); /* create a spring force that connects two particles. * note that there is more than one way to create a spring. * in our case the restlength of the spring is defined by the diff --git a/processing-library/teilchen/examples/Lesson06_Springs/Lesson06_Springs.pde b/processing-library/teilchen/examples/Lesson05_Springs/Lesson05_Springs.pde similarity index 90% rename from processing-library/teilchen/examples/Lesson06_Springs/Lesson06_Springs.pde rename to processing-library/teilchen/examples/Lesson05_Springs/Lesson05_Springs.pde index 4c2f616..6ca3afa 100644 --- a/processing-library/teilchen/examples/Lesson06_Springs/Lesson06_Springs.pde +++ b/processing-library/teilchen/examples/Lesson05_Springs/Lesson05_Springs.pde @@ -8,8 +8,7 @@ import teilchen.util.*; /* - * this sketch shows 1 how to create a viscous drag to slow motion eventually - * down. 2 how to create a spring that connects two particles. + * this sketch demonstrates how to connect multiple particles with springs. */ Physics mPhysics; Particle mRoot; @@ -20,7 +19,7 @@ void setup() { /* create a particle system */ mPhysics = new Physics(); /* create a particle to which we will connect springs */ - mRoot = mPhysics.makeParticle(width / 2, height / 2, 0.0f); + mRoot = mPhysics.makeParticle(width / 2.0f, height / 2.0f, 0.0f); /* we give the root particle a higher mass so it doesn t move as easily */ mRoot.mass(30); } diff --git a/processing-library/teilchen/examples/Lesson07_StableQuads/Lesson07_StableQuads.pde b/processing-library/teilchen/examples/Lesson06_StableQuads/Lesson06_StableQuads.pde similarity index 92% rename from processing-library/teilchen/examples/Lesson07_StableQuads/Lesson07_StableQuads.pde rename to processing-library/teilchen/examples/Lesson06_StableQuads/Lesson06_StableQuads.pde index eee4854..19cc141 100644 --- a/processing-library/teilchen/examples/Lesson07_StableQuads/Lesson07_StableQuads.pde +++ b/processing-library/teilchen/examples/Lesson06_StableQuads/Lesson06_StableQuads.pde @@ -7,6 +7,10 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to connect four particles and six springs to form a + * `StableSpringQuad` a construct that allows to emulate something similar to a *body*. + */ Physics mPhysics; Particle mRoot; void settings() { diff --git a/processing-library/teilchen/examples/Lesson08_Sticks/Lesson08_Sticks.pde b/processing-library/teilchen/examples/Lesson07_Sticks/Lesson07_Sticks.pde similarity index 90% rename from processing-library/teilchen/examples/Lesson08_Sticks/Lesson08_Sticks.pde rename to processing-library/teilchen/examples/Lesson07_Sticks/Lesson07_Sticks.pde index adcb3f3..70fc671 100644 --- a/processing-library/teilchen/examples/Lesson08_Sticks/Lesson08_Sticks.pde +++ b/processing-library/teilchen/examples/Lesson07_Sticks/Lesson07_Sticks.pde @@ -7,6 +7,11 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to use a stick to connect two particles. `Stick` is similar to + * `Spring` except that it does not use forces to move particles which results in a more + * *stiff* behavior. + */ Physics mPhysics; Particle[] mParticles; void settings() { diff --git a/processing-library/teilchen/examples/Lesson09_Cloth/Lesson09_Cloth.pde b/processing-library/teilchen/examples/Lesson08_Cloth/Lesson08_Cloth.pde similarity index 95% rename from processing-library/teilchen/examples/Lesson09_Cloth/Lesson09_Cloth.pde rename to processing-library/teilchen/examples/Lesson08_Cloth/Lesson08_Cloth.pde index d67ca05..97a1396 100644 --- a/processing-library/teilchen/examples/Lesson09_Cloth/Lesson09_Cloth.pde +++ b/processing-library/teilchen/examples/Lesson08_Cloth/Lesson08_Cloth.pde @@ -7,10 +7,12 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrate how to use particles and springs to emulate a piece of cloth. + */ static final int GRID_WIDTH = 32; static final int GRID_HEIGHT = 16; Physics mPhysics; -Particle[][] mParticles; Attractor mAttractor; void settings() { size(640, 480, P3D); @@ -27,7 +29,7 @@ void setup() { mAttractor.strength(-15000); mAttractor.radius(300); mPhysics.add(mAttractor); - mParticles = new Particle[GRID_WIDTH][GRID_HEIGHT]; + Particle[][] mParticles = new Particle[GRID_WIDTH][GRID_HEIGHT]; /* setup cloth */ float mGridStepX = ((float) width / GRID_WIDTH); float mGridStepY = (((float) height * 0.5f) / GRID_HEIGHT); diff --git a/processing-library/teilchen/examples/Lesson04_LineDeflector/Lesson04_LineDeflector.pde b/processing-library/teilchen/examples/Lesson09_LineDeflector/Lesson09_LineDeflector.pde similarity index 89% rename from processing-library/teilchen/examples/Lesson04_LineDeflector/Lesson04_LineDeflector.pde rename to processing-library/teilchen/examples/Lesson09_LineDeflector/Lesson09_LineDeflector.pde index 73c789c..c5c2edc 100644 --- a/processing-library/teilchen/examples/Lesson04_LineDeflector/Lesson04_LineDeflector.pde +++ b/processing-library/teilchen/examples/Lesson09_LineDeflector/Lesson09_LineDeflector.pde @@ -8,7 +8,8 @@ import teilchen.util.*; /* - * this sketch shows 1 how to create and use line deflectors 2 how to use 'ShortLivedParticle' + * this sketch demonstrates how to create and use `LineDeflector2D` and how to use + * `ShortLivedParticle` a particle that only exists for a defined period of time. */ Physics mPhysics; LineDeflector2D mDeflector; @@ -19,8 +20,8 @@ void setup() { /* create a particle system */ mPhysics = new Physics(); mDeflector = new LineDeflector2D(); - mDeflector.a().set(50, height / 2); - mDeflector.b().set(width - 50, height / 2 - 100); + mDeflector.a().set(50, height / 2.0f); + mDeflector.b().set(width - 50, height / 2.0f - 100); mPhysics.add(mDeflector); /* create gravity */ Gravity myGravity = new Gravity(); diff --git a/processing-library/teilchen/examples/Lesson04_PlaneDeflector/Lesson04_PlaneDeflector.pde b/processing-library/teilchen/examples/Lesson10_PlaneDeflector/Lesson10_PlaneDeflector.pde similarity index 93% rename from processing-library/teilchen/examples/Lesson04_PlaneDeflector/Lesson04_PlaneDeflector.pde rename to processing-library/teilchen/examples/Lesson10_PlaneDeflector/Lesson10_PlaneDeflector.pde index 0edde08..4672c3a 100644 --- a/processing-library/teilchen/examples/Lesson04_PlaneDeflector/Lesson04_PlaneDeflector.pde +++ b/processing-library/teilchen/examples/Lesson10_PlaneDeflector/Lesson10_PlaneDeflector.pde @@ -8,8 +8,8 @@ import teilchen.util.*; /* - * this sketch shows 1 how to create and use plane deflectors 2 how to use - * 'ShortLivedParticle' + * this sketch demonstrates how to create and use ``PlaneDeflector` and how to use + * `ShortLivedParticle` a particle that only exists for a defined period of time. */ Physics mPhysics; PlaneDeflector mDeflector; @@ -28,7 +28,7 @@ void setup() { */ mDeflector = new PlaneDeflector(); /* set plane origin into the center of the screen */ - mDeflector.plane().origin.set(width / 2, height / 2, 0); + mDeflector.plane().origin.set(width / 2.0f, height / 2.0f, 0); mDeflector.plane().normal.set(0, -1, 0); /* the coefficient of restitution defines how hard particles bounce of the deflector */ mDeflector.coefficientofrestitution(0.7f); diff --git a/processing-library/teilchen/examples/Lesson10_WanderBehavior/Lesson10_WanderBehavior.pde b/processing-library/teilchen/examples/Lesson11_WanderBehavior/Lesson11_WanderBehavior.pde similarity index 87% rename from processing-library/teilchen/examples/Lesson10_WanderBehavior/Lesson10_WanderBehavior.pde rename to processing-library/teilchen/examples/Lesson11_WanderBehavior/Lesson11_WanderBehavior.pde index 7ec2613..1fb4180 100644 --- a/processing-library/teilchen/examples/Lesson10_WanderBehavior/Lesson10_WanderBehavior.pde +++ b/processing-library/teilchen/examples/Lesson11_WanderBehavior/Lesson11_WanderBehavior.pde @@ -8,7 +8,8 @@ import teilchen.util.*; /* - * this sketch shows how to assign an 'wander' behavior to a particle. + * this sketch demonstrates how to use behaviors. it combines `Wander` and `Motor` behaviors + * to turn a `BehaviorParticle` into an autonomously moving *agent*. */ Physics mPhysics; BehaviorParticle mParticle; @@ -24,7 +25,7 @@ void setup() { mPhysics.add(new ViscousDrag()); /* create particles */ mParticle = mPhysics.makeParticle(BehaviorParticle.class); - mParticle.position().set(width / 2, height / 2); + mParticle.position().set(width / 2.0f, height / 2.0f); mParticle.maximumInnerForce(100); mParticle.radius(10); /* create behavior */ diff --git a/processing-library/teilchen/examples/Lesson11_ArrivalBehavior/Lesson11_ArrivalBehavior.pde b/processing-library/teilchen/examples/Lesson12_ArrivalBehavior/Lesson12_ArrivalBehavior.pde similarity index 92% rename from processing-library/teilchen/examples/Lesson11_ArrivalBehavior/Lesson11_ArrivalBehavior.pde rename to processing-library/teilchen/examples/Lesson12_ArrivalBehavior/Lesson12_ArrivalBehavior.pde index 407d1a0..d240753 100644 --- a/processing-library/teilchen/examples/Lesson11_ArrivalBehavior/Lesson11_ArrivalBehavior.pde +++ b/processing-library/teilchen/examples/Lesson12_ArrivalBehavior/Lesson12_ArrivalBehavior.pde @@ -8,7 +8,8 @@ import teilchen.util.*; /* - * this sketch shows how to assign an 'arrival' behavior to a particle. + * this sketch demonstrates how to use behaviors. it appliies the `Arrival` behavior to make a + * `BehaviorParticle` arrive at a certain location. */ Physics mPhysics; BehaviorParticle mParticle; diff --git a/processing-library/teilchen/examples/LessonX01_Overlap/LessonX01_Overlap.pde b/processing-library/teilchen/examples/LessonX01_Overlap/LessonX01_Overlap.pde index 74c7f72..68d52f9 100644 --- a/processing-library/teilchen/examples/LessonX01_Overlap/LessonX01_Overlap.pde +++ b/processing-library/teilchen/examples/LessonX01_Overlap/LessonX01_Overlap.pde @@ -8,8 +8,8 @@ import teilchen.util.*; /* - * this sketch is exactly like Lesson06_Springs, except that it also shows how - * to resolveOverlap overlaps. + * this sketch is exactly like `Lesson06_Springs` except that it also shows how to resolve + * overlaps of particles by moving particles apart manipulating their position directly. */ static final float PARTICLE_RADIUS = 13; Physics mPhysics; @@ -22,7 +22,7 @@ void setup() { /* create drag */ mPhysics.add(new ViscousDrag()); mPhysics.add(new Gravity(new PVector(0, 100f, 0))); - mRoot = mPhysics.makeParticle(width / 2, height / 2, 0.0f); + mRoot = mPhysics.makeParticle(width / 2.0f, height / 2.0f, 0.0f); mRoot.mass(30); mRoot.fixed(true); mRoot.radius(PARTICLE_RADIUS); @@ -39,7 +39,7 @@ void draw() { } /* move overlapping particles away from each other */ for (int i = 0; i < 10; i++) { - mRoot.position().set(width / 2, height / 2, 0.0f); // a bit of a 'hack' + mRoot.position().set(width / 2.0f, height / 2.0f, 0.0f); // a bit of a 'hack' Overlap.resolveOverlap(mPhysics.particles()); } /* update the particle system */ diff --git a/processing-library/teilchen/examples/LessonX02_Collisions/LessonX02_Collisions.pde b/processing-library/teilchen/examples/LessonX02_Collisions/LessonX02_Collisions.pde index 5c74dd0..69f746c 100644 --- a/processing-library/teilchen/examples/LessonX02_Collisions/LessonX02_Collisions.pde +++ b/processing-library/teilchen/examples/LessonX02_Collisions/LessonX02_Collisions.pde @@ -7,6 +7,10 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to use `CollisionManager` to resolve particle collisions by + * applying temporary springs pushing 2 colliding particles appart. + */ static final float PARTICLE_SIZE = 12; CollisionManager mCollision; Physics mPhysics; diff --git a/processing-library/teilchen/examples/LessonX03_ParticlesLeavingTrails/LessonX03_ParticlesLeavingTrails.pde b/processing-library/teilchen/examples/LessonX03_ParticlesLeavingTrails/LessonX03_ParticlesLeavingTrails.pde index 2ee6f5d..9bbd8d4 100644 --- a/processing-library/teilchen/examples/LessonX03_ParticlesLeavingTrails/LessonX03_ParticlesLeavingTrails.pde +++ b/processing-library/teilchen/examples/LessonX03_ParticlesLeavingTrails/LessonX03_ParticlesLeavingTrails.pde @@ -7,6 +7,9 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to use `ParticleTrail` to make particles leave a trail. + */ Physics mPhysics; ArrayList mTrails; Attractor mAttractor; @@ -44,14 +47,7 @@ void setup() { myParticleTrail.mass(0.5f); mTrails.add(myParticleTrail); } - resetParticles(width / 2, height / 2); -} -void resetParticles(float x, float y) { - for (ParticleTrail myTrails : mTrails) { - myTrails.particle().position().set(x + random(-10, 10), y + random(-10, 10), 0); - myTrails.particle().velocity().set(random(-10, 10), random(-10, 10), random(-10, 10)); - myTrails.fragments().clear(); - } + resetParticles(width / 2.0f, height / 2.0f); } void draw() { /* set attractor to mouse position */ @@ -65,6 +61,16 @@ void draw() { drawTrail(myTrail); } } +void mousePressed() { + resetParticles(mouseX, mouseY); +} +void resetParticles(float x, float y) { + for (ParticleTrail myTrails : mTrails) { + myTrails.particle().position().set(x + random(-10, 10), y + random(-10, 10), 0); + myTrails.particle().velocity().set(random(-10, 10), random(-10, 10), random(-10, 10)); + myTrails.fragments().clear(); + } +} void drawTrail(ParticleTrail theTrail) { final ArrayList mFragments = theTrail.fragments(); final Particle mParticle = theTrail.particle(); @@ -102,6 +108,3 @@ void drawTrail(ParticleTrail theTrail) { mParticle.position().z); } } -void mousePressed() { - resetParticles(mouseX, mouseY); -} diff --git a/processing-library/teilchen/examples/LessonX04_StickMan/LessonX04_StickMan.pde b/processing-library/teilchen/examples/LessonX04_StickMan/LessonX04_StickMan.pde index 37259fa..3326183 100644 --- a/processing-library/teilchen/examples/LessonX04_StickMan/LessonX04_StickMan.pde +++ b/processing-library/teilchen/examples/LessonX04_StickMan/LessonX04_StickMan.pde @@ -8,13 +8,12 @@ import teilchen.util.*; /* - * this demo shows some advanced use of particles, springs and attractors to - * create stickmen. + * this sketch demonstratwa some advanced use of particles, springs ( e.g `MuscleSpring` ) + * and attractors to create a group of `StickMan`. */ Physics mPhysics; Attractor mAttractor; Gravity mGravity; -ViscousDrag mViscousDrag; StickMan[] mMyStickMan; void settings() { size(640, 480, P3D); @@ -27,13 +26,13 @@ void setup() { mGravity = new Gravity(); mGravity.force().y = 20; mPhysics.add(mGravity); - mViscousDrag = new ViscousDrag(); + ViscousDrag mViscousDrag = new ViscousDrag(); mViscousDrag.coefficient = 0.85f; mPhysics.add(mViscousDrag); mAttractor = new Attractor(); mAttractor.radius(500); mAttractor.strength(0); - mAttractor.position().set(width / 2, height / 2); + mAttractor.position().set(width / 2.0f, height / 2.0f); mPhysics.add(mAttractor); mMyStickMan = new StickMan[20]; for (int i = 0; i < mMyStickMan.length; i++) { diff --git a/processing-library/teilchen/examples/LessonX05_AngleConstraints/LessonX05_AngleConstraints.pde b/processing-library/teilchen/examples/LessonX05_AngleConstraints/LessonX05_AngleConstraints.pde index 7b1345e..63e4261 100644 --- a/processing-library/teilchen/examples/LessonX05_AngleConstraints/LessonX05_AngleConstraints.pde +++ b/processing-library/teilchen/examples/LessonX05_AngleConstraints/LessonX05_AngleConstraints.pde @@ -7,6 +7,9 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to contraint the angle between two springs or two sticks. + */ Physics mPhysics; Particle mParticleA; Particle mParticleB; @@ -31,10 +34,10 @@ void setup() { mParticleB = mPhysics.makeParticle(); mParticleC = mPhysics.makeParticle(); mParticleD = mPhysics.makeParticle(); - mParticleA.position().set(width / 2 + 50, height / 3); - mParticleB.position().set(width / 2, height - height / 1.75f); - mParticleC.position().set(width / 2, height - height / 4); - mParticleD.position().set(width / 2, height - height / 8); + mParticleA.position().set(width / 2.0f + 50, height / 3.0f); + mParticleB.position().set(width / 2.0f, height - height / 1.75f); + mParticleC.position().set(width / 2.0f, height - height / 4.0f); + mParticleD.position().set(width / 2.0f, height - height / 8.0f); mParticleA.radius(7); mParticleB.radius(3); mParticleC.radius(10); diff --git a/processing-library/teilchen/examples/LessonX06_Ducklings/LessonX06_Ducklings.pde b/processing-library/teilchen/examples/LessonX06_Ducklings/LessonX06_Ducklings.pde index 2ccc834..9258ecd 100644 --- a/processing-library/teilchen/examples/LessonX06_Ducklings/LessonX06_Ducklings.pde +++ b/processing-library/teilchen/examples/LessonX06_Ducklings/LessonX06_Ducklings.pde @@ -8,8 +8,8 @@ import teilchen.util.*; /* - * this demo shows how to add behaviors to particles. in this example the - * arrival behavior. + * this sketch demonstrates how to use `Arrival` behaviors with particles to create a group of + * ducklings. */ Physics mPhysics; ArrayList mDucklings; @@ -18,7 +18,6 @@ void settings() { size(640, 480, P3D); } void setup() { - frameRate(60); colorMode(RGB, 1.0f); /* physics */ mPhysics = new Physics(); diff --git a/processing-library/teilchen/examples/LessonX07_CubicleWorld/LessonX07_CubicleWorld.pde b/processing-library/teilchen/examples/LessonX07_CubicleWorld/LessonX07_CubicleWorld.pde index f615a20..e47582a 100644 --- a/processing-library/teilchen/examples/LessonX07_CubicleWorld/LessonX07_CubicleWorld.pde +++ b/processing-library/teilchen/examples/LessonX07_CubicleWorld/LessonX07_CubicleWorld.pde @@ -7,10 +7,16 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to use `CubicleWorld` to separate a given space into equally + * sized cubes in order to only draw paticles from a specific cube. this mechanism is helpful + * to avoid decrease the in demand for computational resources in particle systems with large + * numbers of particles. + */ final int WORLD_NUMBER_OF_CUBICLES = 15; final float WORLD_CUBICLE_SCALE = 20; final float WORLD_SCALE = WORLD_NUMBER_OF_CUBICLES * WORLD_CUBICLE_SCALE; -final boolean showCubicles = true; +final boolean mShowCubicles = true; final PVector mPosition = new PVector(); float mRotationZ = 0.1f; CubicleWorld mCubicleWorld; @@ -28,33 +34,30 @@ void setup() { mCubicleWorld.transform().translation.set(-WORLD_SCALE / 2, -WORLD_SCALE / 2, -WORLD_SCALE / 2); mCubicleWorldView = new CubicleWorldView(mCubicleWorld); mCubicleWorldView.color_empty = color(0, 1); - mCubicleWorldView.color_full = color(0, 4); + mCubicleWorldView.color_full = color(0, 2); mCubicleWorld.add(new MCubicleEntity()); } void draw() { - /* handle entities */ - if (frameRate > 30) { - addRandomEntities(2); - } + /* add entities */ + addRandomEntities(10); mCubicleWorld.update(); ArrayList mEntities = mCubicleWorld.getLocalEntities(mPosition, 1); /* draw things */ background(255); pushMatrix(); - translate(width / 2, height / 2, 0); + translate(width / 2.0f, height / 2.0f, 0); /* rotate */ if (mousePressed) { mRotationZ += (mouseX * 0.01f - mRotationZ) * 0.05f; } else { - mPosition.x = mouseX - width / 2; - mPosition.y = mouseY - height / 2; + mPosition.x = mouseX - width / 2.0f; + mPosition.y = mouseY - height / 2.0f; } rotateX(THIRD_PI); rotateZ(mRotationZ); /* draw cubicle world */ - if (showCubicles) { - strokeWeight(0.1f); - stroke(0, 127); + if (mShowCubicles) { + strokeWeight(1.0f / mCubicleWorld.cellscale().x); // unscale stroke weight noFill(); mCubicleWorldView.draw(g); } diff --git a/processing-library/teilchen/examples/LessonX08_Schwarm/LessonX08_Schwarm.pde b/processing-library/teilchen/examples/LessonX08_Schwarm/LessonX08_Schwarm.pde index de3205b..403efa8 100644 --- a/processing-library/teilchen/examples/LessonX08_Schwarm/LessonX08_Schwarm.pde +++ b/processing-library/teilchen/examples/LessonX08_Schwarm/LessonX08_Schwarm.pde @@ -7,6 +7,10 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to create a complex swarm behavior by combining the four simple + * behaviors `Separation`, `Alignment`, `Cohesion` and `Wander` ( plus `Motor` ). + */ Physics mPhysics; ArrayList mSwarmEntities; void settings() { diff --git a/processing-library/teilchen/examples/LessonX09_TriangleDeflector/LessonX09_TriangleDeflector.pde b/processing-library/teilchen/examples/LessonX09_TriangleDeflector/LessonX09_TriangleDeflector.pde index 5d5f6c5..c203f4d 100644 --- a/processing-library/teilchen/examples/LessonX09_TriangleDeflector/LessonX09_TriangleDeflector.pde +++ b/processing-library/teilchen/examples/LessonX09_TriangleDeflector/LessonX09_TriangleDeflector.pde @@ -7,6 +7,11 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to use `TriangleDeflectors` to make particles bounce off two + * triangles. it also demonstrates how to use `MortalParticle` to remove particles + * automatically once they leave the screen. + */ Physics mPhysics; ArrayList mTriangleDeflectors; void settings() { @@ -22,9 +27,7 @@ void setup() { /* triangle deflectors */ final PVector[] mVertices = new PVector[]{new PVector(0, 0, 0), new PVector(width, height, 0), - new PVector(0, - height, - 0), + new PVector(0, height, 0), new PVector(0, 0, 0), new PVector(width, 0, 0), new PVector(width, height, 0),}; @@ -34,23 +37,17 @@ void setup() { void draw() { if (mousePressed) { /* create and add a particle to the system */ - Particle mParticle = mPhysics.makeParticle(); + MyMortalParticle mParticle = new MyMortalParticle(); + mPhysics.add(mParticle); /* set particle to mouse position with random velocity */ - mParticle.position().set(mouseX, random(height), height / 2); + mParticle.position().set(mouseX, random(height), height / 2.0f); mParticle.velocity().set(random(-20, 20), 0, random(20)); } final float mDeltaTime = 1.0f / frameRate; mPhysics.step(mDeltaTime); - /* remove particles */ - for (int i = 0; i < mPhysics.particles().size(); i++) { - Particle mParticle = mPhysics.particles(i); - if (mParticle.position().z < -height) { - mPhysics.particles().remove(i); - } - } /* draw particles */ background(255); - camera(width / 2, mouseY + height, height * 1.3f - mouseY, width / 2, height / 2, 0, 0, 1, 0); + camera(width / 2.0f, mouseY + height, height * 1.3f - mouseY, width / 2.0f, height / 2.0f, 0, 0, 1, 0); noStroke(); sphereDetail(10); for (int i = 0; i < mPhysics.particles().size(); i++) { @@ -73,3 +70,8 @@ void draw() { /* finally remove the collision tag */ mPhysics.removeTags(); } +class MyMortalParticle extends MortalParticle { + boolean isDead() { + return position().z < -height; + } +} diff --git a/processing-library/teilchen/examples/LessonX10_TriangleDeflector2D/LessonX10_TriangleDeflector2D.pde b/processing-library/teilchen/examples/LessonX10_TriangleDeflector2D/LessonX10_TriangleDeflector2D.pde index 58fb3c2..c3ed70b 100644 --- a/processing-library/teilchen/examples/LessonX10_TriangleDeflector2D/LessonX10_TriangleDeflector2D.pde +++ b/processing-library/teilchen/examples/LessonX10_TriangleDeflector2D/LessonX10_TriangleDeflector2D.pde @@ -7,6 +7,11 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to use `TriangleDeflectors` in a 2D context to make particles + * bounce off a triangle ( that looks like a line ). it also demonstrates how to use + * `MortalParticle` to remove particles automatically once they leave the screen. + */ Physics mPhysics; TriangleDeflector mTriangleDeflector; void settings() { @@ -29,13 +34,6 @@ void setup() { void draw() { final float mDeltaTime = 1.0f / frameRate; mPhysics.step(mDeltaTime); - /* remove particles */ - for (int i = 0; i < mPhysics.particles().size(); i++) { - Particle mParticle = mPhysics.particles(i); - if (mParticle.position().y > height || mParticle.still()) { - mPhysics.particles().remove(i); //@TODO(this might cause an exception. should be replaced by iterator) - } - } /* draw particles */ background(255); for (int i = 0; i < mPhysics.particles().size(); i++) { @@ -57,11 +55,17 @@ void draw() { line(mTriangleDeflector.a().x, mTriangleDeflector.a().y, mTriangleDeflector.b().x, mTriangleDeflector.b().y); /* finally remove the collision tag */ mPhysics.removeTags(); + if (mousePressed) { + /* create and add a particle to the system */ + MyMortalParticle mParticle = new MyMortalParticle(); + mPhysics.add(mParticle); + /* set particle to mouse position with random velocity */ + mParticle.position().set(mouseX, mouseY); + mParticle.velocity().set(random(-20, 20), 0); + } } -void mousePressed() { - /* create and add a particle to the system */ - Particle mParticle = mPhysics.makeParticle(); - /* set particle to mouse position with random velocity */ - mParticle.position().set(mouseX, mouseY); - mParticle.velocity().set(random(-20, 20), 0); +class MyMortalParticle extends MortalParticle { + boolean isDead() { + return position().y > height || still(); + } } diff --git a/processing-library/teilchen/examples/LessonX11_NonIntersectingStructures/LessonX11_NonIntersectingStructures.pde b/processing-library/teilchen/examples/LessonX11_NonIntersectingStructures/LessonX11_NonIntersectingStructures.pde deleted file mode 100644 index 1374143..0000000 --- a/processing-library/teilchen/examples/LessonX11_NonIntersectingStructures/LessonX11_NonIntersectingStructures.pde +++ /dev/null @@ -1,66 +0,0 @@ -import teilchen.*; -import teilchen.behavior.*; -import teilchen.constraint.*; -import teilchen.cubicle.*; -import teilchen.force.*; -import teilchen.integration.*; -import teilchen.util.*; - - -// @TODO(not fully functional yet) -Physics mPhysics; -Particle[] mParticles; -void settings() { - size(640, 480, P3D); -} -void setup() { - frameRate(60); - smooth(); - mPhysics = new Physics(); - /* we chose verlet integration as it integrates much more nicely with sticks ( and constraints in general ) */ - Verlet myVerlet = new Verlet(); - myVerlet.damping(0.99f); - mPhysics.setIntegratorRef(myVerlet); - Gravity mGravity = new Gravity(0, 100, 0); - mPhysics.add(mGravity); - /* setup sticks to form mParticle whip */ - mParticles = new Particle[16]; - float mSegmentLength = 10.0f; - /* create sticks */ - final ArrayList mSticks = new ArrayList(); - for (int i = 0; i < mParticles.length; i++) { - mParticles[i] = mPhysics.makeParticle(i * mSegmentLength, 0, 0, 0.1f); - if (i > 0) { - final Stick mConnection = new Stick(mParticles[i - 1], mParticles[i], mSegmentLength); -// mConnection.strength(3); -// mConnection.damping(0.99f); - mSticks.add(mConnection); - mPhysics.add(mConnection); - } - } - /* create line intersection mechanism */ - for (Particle mParticle : mParticles) { - LineIntersectionConstraint mLineIntersections = new LineIntersectionConstraint(mParticle); - mLineIntersections.intersecting_lines().addAll(mSticks); - mPhysics.add(mLineIntersections); - mLineIntersections.DEBUG_VIEW = g; - } - /* fix root particle so it can stick to the mouse later */ - mParticles[0].fixed(true); -} -void draw() { - background(255); - /* stick root particle to mouse */ - mParticles[0].position().set(mouseX, mouseY); - /* update */ - mPhysics.step(1.0f / frameRate); - /* draw sticks with descending stroke weight */ - stroke(0, 192); - for (int i = 1; i < mParticles.length; i++) { - Particle p1 = mParticles[i - 1]; - Particle p2 = mParticles[i]; - final float mStrokeWeight = 4.0f * (1.0f - (float) i / mParticles.length); - strokeWeight(mStrokeWeight); - line(p1.position().x, p1.position().y, p1.position().z, p2.position().x, p2.position().y, p2.position().z); - } -} diff --git a/processing-library/teilchen/examples/LessonX12_Pendulum/LessonX12_Pendulum.pde b/processing-library/teilchen/examples/LessonX11_Pendulum/LessonX11_Pendulum.pde similarity index 87% rename from processing-library/teilchen/examples/LessonX12_Pendulum/LessonX12_Pendulum.pde rename to processing-library/teilchen/examples/LessonX11_Pendulum/LessonX11_Pendulum.pde index b7f2ae2..7084c82 100644 --- a/processing-library/teilchen/examples/LessonX12_Pendulum/LessonX12_Pendulum.pde +++ b/processing-library/teilchen/examples/LessonX11_Pendulum/LessonX11_Pendulum.pde @@ -7,6 +7,10 @@ import teilchen.integration.*; import teilchen.util.*; +/* + * this sketch demonstrates how to create a pendulum from two particles, a spring and a pulse + * force. + */ Physics mPhysics; Particle mPendulumRoot; Particle mPendulumTip; @@ -19,10 +23,10 @@ void setup() { Gravity mGravity = new Gravity(); mPhysics.add(mGravity); mPendulumRoot = mPhysics.makeParticle(0, 0, 0, 0.05f); - mPendulumRoot.position().set(width / 2, 100); + mPendulumRoot.position().set(width / 2.0f, 100); mPendulumRoot.fixed(true); mPendulumTip = mPhysics.makeParticle(0, 0, 0, 0.05f); - float mSegmentLength = height / 2; + float mSegmentLength = height / 2.0f; Spring mConnection = new Spring(mPendulumRoot, mPendulumTip, mSegmentLength); mConnection.damping(0.0f); mConnection.strength(10); diff --git a/processing-library/teilchen/library/teilchen.jar b/processing-library/teilchen/library/teilchen.jar index f01b969..f507d4e 100644 Binary files a/processing-library/teilchen/library/teilchen.jar and b/processing-library/teilchen/library/teilchen.jar differ diff --git a/processing-library/teilchen/reference/allclasses-frame.html b/processing-library/teilchen/reference/allclasses-frame.html index 7859b49..985088f 100644 --- a/processing-library/teilchen/reference/allclasses-frame.html +++ b/processing-library/teilchen/reference/allclasses-frame.html @@ -2,9 +2,9 @@ - + All Classes - + @@ -26,7 +26,6 @@

All Classes

  • CollisionManager.CollisionSpring
  • CollisionManager.CollisionStick
  • CollisionManager.ResolverType
  • -
  • ConditionalParticle
  • CubicleAtom
  • CubicleEntity
  • CubicleParticle
  • @@ -37,9 +36,9 @@

    All Classes

  • DrawLib
  • Euler
  • Flee
  • -
  • FlowField
  • -
  • FlowFieldForce
  • -
  • FlowFieldForceMOUSE
  • +
  • FlowField
  • +
  • FlowFieldForce
  • +
  • FlowFieldForceMOUSE
  • Gravity
  • IBehavior
  • IBehaviorParticle
  • @@ -56,6 +55,7 @@

    All Classes

  • LineIntersectionConstraint
  • Matrix3f
  • Midpoint
  • +
  • MortalParticle
  • Motor
  • MuscleSpring
  • Overlap
  • @@ -92,12 +92,12 @@

    All Classes

  • Util.ProximityStructure
  • Vector3i
  • Vector4f
  • -
  • VectorField
  • -
  • VectorFieldGenerator
  • -
  • VectorFieldGeneratorAVERAGEUNITS
  • -
  • VectorFieldGeneratorRANDOM
  • +
  • VectorField
  • +
  • VectorFieldGenerator
  • +
  • VectorFieldGeneratorAVERAGEUNITS
  • +
  • VectorFieldGeneratorRANDOM
  • VectorfieldParticle
  • -
  • VectorFieldUnit
  • +
  • VectorFieldUnit
  • Verhalten
  • Verlet
  • ViscousDrag
  • diff --git a/processing-library/teilchen/reference/allclasses-noframe.html b/processing-library/teilchen/reference/allclasses-noframe.html index 9b2c2f2..4b1b6c5 100644 --- a/processing-library/teilchen/reference/allclasses-noframe.html +++ b/processing-library/teilchen/reference/allclasses-noframe.html @@ -2,9 +2,9 @@ - + All Classes - + @@ -26,7 +26,6 @@

    All Classes

  • CollisionManager.CollisionSpring
  • CollisionManager.CollisionStick
  • CollisionManager.ResolverType
  • -
  • ConditionalParticle
  • CubicleAtom
  • CubicleEntity
  • CubicleParticle
  • @@ -37,9 +36,9 @@

    All Classes

  • DrawLib
  • Euler
  • Flee
  • -
  • FlowField
  • -
  • FlowFieldForce
  • -
  • FlowFieldForceMOUSE
  • +
  • FlowField
  • +
  • FlowFieldForce
  • +
  • FlowFieldForceMOUSE
  • Gravity
  • IBehavior
  • IBehaviorParticle
  • @@ -56,6 +55,7 @@

    All Classes

  • LineIntersectionConstraint
  • Matrix3f
  • Midpoint
  • +
  • MortalParticle
  • Motor
  • MuscleSpring
  • Overlap
  • @@ -92,12 +92,12 @@

    All Classes

  • Util.ProximityStructure
  • Vector3i
  • Vector4f
  • -
  • VectorField
  • -
  • VectorFieldGenerator
  • -
  • VectorFieldGeneratorAVERAGEUNITS
  • -
  • VectorFieldGeneratorRANDOM
  • +
  • VectorField
  • +
  • VectorFieldGenerator
  • +
  • VectorFieldGeneratorAVERAGEUNITS
  • +
  • VectorFieldGeneratorRANDOM
  • VectorfieldParticle
  • -
  • VectorFieldUnit
  • +
  • VectorFieldUnit
  • Verhalten
  • Verlet
  • ViscousDrag
  • diff --git a/processing-library/teilchen/reference/constant-values.html b/processing-library/teilchen/reference/constant-values.html index ec9ef8a..2a4c3c9 100644 --- a/processing-library/teilchen/reference/constant-values.html +++ b/processing-library/teilchen/reference/constant-values.html @@ -2,9 +2,9 @@ - + Constant Field Values - + diff --git a/processing-library/teilchen/reference/help-doc.html b/processing-library/teilchen/reference/help-doc.html index 9f79aa6..5abb0d6 100644 --- a/processing-library/teilchen/reference/help-doc.html +++ b/processing-library/teilchen/reference/help-doc.html @@ -2,9 +2,9 @@ - + API Help - + diff --git a/processing-library/teilchen/reference/index-files/index-1.html b/processing-library/teilchen/reference/index-files/index-1.html index 3ddc365..1e5d233 100644 --- a/processing-library/teilchen/reference/index-files/index-1.html +++ b/processing-library/teilchen/reference/index-files/index-1.html @@ -2,9 +2,9 @@ - + A-Index - + @@ -146,9 +146,9 @@

    A

     
    active(boolean) - Method in class teilchen.force.Attractor
     
    -
    active() - Method in class teilchen.force.flowfield.FlowField
    +
    active() - Method in class teilchen.force.FlowField
     
    -
    active(boolean) - Method in class teilchen.force.flowfield.FlowField
    +
    active(boolean) - Method in class teilchen.force.FlowField
     
    active() - Method in class teilchen.force.Gravity
     
    @@ -178,9 +178,9 @@

    A

     
    active(boolean) - Method in class teilchen.force.TriangleDeflector
     
    -
    active() - Method in class teilchen.force.vectorfield.VectorField
    +
    active() - Method in class teilchen.force.VectorField
     
    -
    active(boolean) - Method in class teilchen.force.vectorfield.VectorField
    +
    active(boolean) - Method in class teilchen.force.VectorField
     
    active() - Method in class teilchen.force.ViscousDrag
     
    @@ -210,7 +210,7 @@

    A

     
    addConstraints(ArrayList<? extends IConstraint>) - Method in class teilchen.Physics
     
    -
    addForce(FlowFieldForce) - Method in class teilchen.force.flowfield.FlowField
    +
    addForce(FlowFieldForce) - Method in class teilchen.force.FlowField
     
    addForces(ArrayList<? extends IForce>) - Method in class teilchen.Physics
     
    @@ -282,7 +282,7 @@

    A

     
    apply(float, Physics) - Method in class teilchen.force.DirectedAttractor
     
    -
    apply(float, Physics) - Method in class teilchen.force.flowfield.FlowField
    +
    apply(float, Physics) - Method in class teilchen.force.FlowField
     
    apply(float, Physics) - Method in class teilchen.force.Gravity
     
    @@ -302,7 +302,7 @@

    A

     
    apply(float, Physics) - Method in class teilchen.force.TriangleDeflector
     
    -
    apply(float, Physics) - Method in class teilchen.force.vectorfield.VectorField
    +
    apply(float, Physics) - Method in class teilchen.force.VectorField
     
    apply(float, Physics) - Method in class teilchen.force.ViscousDrag
     
    @@ -310,9 +310,9 @@

    A

     
    apply(Physics) - Method in class teilchen.util.CollisionManager.CollisionStick
     
    -
    applyForce(FlowField) - Method in class teilchen.force.flowfield.FlowFieldForce
    +
    applyForce(FlowField) - Method in class teilchen.force.FlowFieldForce
     
    -
    applyForce(FlowField) - Method in class teilchen.force.flowfield.FlowFieldForceMOUSE
    +
    applyForce(FlowField) - Method in class teilchen.force.FlowFieldForceMOUSE
     
    applyForces(float) - Method in class teilchen.Physics
     
    diff --git a/processing-library/teilchen/reference/index-files/index-10.html b/processing-library/teilchen/reference/index-files/index-10.html index ea0b929..8d8d5eb 100644 --- a/processing-library/teilchen/reference/index-files/index-10.html +++ b/processing-library/teilchen/reference/index-files/index-10.html @@ -2,9 +2,9 @@ - + L-Index - + @@ -107,7 +107,7 @@

    L

    from paul bourke ( http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline3d/ )
    -
    loop(float) - Method in class teilchen.force.flowfield.FlowField
    +
    loop(float) - Method in class teilchen.force.FlowField
     
    loop(float, int) - Method in class teilchen.Physics
     
    diff --git a/processing-library/teilchen/reference/index-files/index-11.html b/processing-library/teilchen/reference/index-files/index-11.html index 12da304..8a88f01 100644 --- a/processing-library/teilchen/reference/index-files/index-11.html +++ b/processing-library/teilchen/reference/index-files/index-11.html @@ -2,9 +2,9 @@ - + M-Index - + @@ -160,6 +160,10 @@

    M

     
    minimumDistance() - Method in class teilchen.util.CollisionManager
     
    +
    MortalParticle - Class in teilchen
    +
     
    +
    MortalParticle() - Constructor for class teilchen.MortalParticle
    +
     
    Motor - Class in teilchen.behavior
     
    Motor() - Constructor for class teilchen.behavior.Motor
    diff --git a/processing-library/teilchen/reference/index-files/index-12.html b/processing-library/teilchen/reference/index-files/index-12.html index fadcdaf..12899a0 100644 --- a/processing-library/teilchen/reference/index-files/index-12.html +++ b/processing-library/teilchen/reference/index-files/index-12.html @@ -2,9 +2,9 @@ - + N-Index - + @@ -72,7 +72,7 @@

    N

    -
    n - Variable in class teilchen.force.flowfield.FlowField
    +
    n - Variable in class teilchen.force.FlowField
     
    NEGATIVE_X - Variable in class teilchen.constraint.ReflectBox
     
    diff --git a/processing-library/teilchen/reference/index-files/index-13.html b/processing-library/teilchen/reference/index-files/index-13.html index 6913a02..98cc135 100644 --- a/processing-library/teilchen/reference/index-files/index-13.html +++ b/processing-library/teilchen/reference/index-files/index-13.html @@ -2,9 +2,9 @@ - + O-Index - + diff --git a/processing-library/teilchen/reference/index-files/index-14.html b/processing-library/teilchen/reference/index-files/index-14.html index a38a076..1b2f747 100644 --- a/processing-library/teilchen/reference/index-files/index-14.html +++ b/processing-library/teilchen/reference/index-files/index-14.html @@ -2,9 +2,9 @@ - + P-Index - + @@ -142,9 +142,9 @@

    P

    position() - Method in class teilchen.force.Attractor
     
    -
    position() - Method in class teilchen.force.flowfield.FlowField
    +
    position() - Method in class teilchen.force.FlowField
     
    -
    position - Variable in class teilchen.force.flowfield.FlowFieldForce
    +
    position - Variable in class teilchen.force.FlowFieldForce
     
    position() - Method in interface teilchen.Particle
     
    diff --git a/processing-library/teilchen/reference/index-files/index-15.html b/processing-library/teilchen/reference/index-files/index-15.html index c85a852..cee7ae0 100644 --- a/processing-library/teilchen/reference/index-files/index-15.html +++ b/processing-library/teilchen/reference/index-files/index-15.html @@ -2,9 +2,9 @@ - + R-Index - + @@ -105,7 +105,7 @@

    R

    range(float, float) - Method in class teilchen.constraint.Angular
     
    -
    range - Variable in class teilchen.force.flowfield.FlowFieldForce
    +
    range - Variable in class teilchen.force.FlowFieldForce
     
    Ray3f - Class in teilchen.util
     
    @@ -154,7 +154,7 @@

    R

     
    removeTags() - Method in class teilchen.Physics
     
    -
    reset() - Method in class teilchen.force.flowfield.FlowField
    +
    reset() - Method in class teilchen.force.FlowField
     
    RESOLVE_SAME_PLACE - Static variable in class teilchen.util.Overlap
     
    diff --git a/processing-library/teilchen/reference/index-files/index-16.html b/processing-library/teilchen/reference/index-files/index-16.html index 909d490..4e14727 100644 --- a/processing-library/teilchen/reference/index-files/index-16.html +++ b/processing-library/teilchen/reference/index-files/index-16.html @@ -2,9 +2,9 @@ - + S-Index - + @@ -74,7 +74,7 @@

    S

    satisfyNeighborConstraints(ArrayList<Particle>, float) - Static method in class teilchen.util.Util
     
    -
    scale() - Method in class teilchen.force.flowfield.FlowField
    +
    scale() - Method in class teilchen.force.FlowField
     
    scale(float, Vector4f) - Method in class teilchen.util.Vector4f
     
    @@ -128,15 +128,15 @@

    S

     
    set(PVector) - Method in class teilchen.util.Vector4f
     
    -
    setAcceleration(PVector) - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    setAcceleration(PVector) - Method in class teilchen.force.VectorFieldUnit
     
    setDirectionRef(PVector) - Method in class teilchen.behavior.Motor
     
    -
    setForce() - Method in class teilchen.force.flowfield.FlowField
    +
    setForce() - Method in class teilchen.force.FlowField
     
    -
    setForce(float, float, PVector, float) - Method in class teilchen.force.flowfield.FlowField
    +
    setForce(float, float, PVector, float) - Method in class teilchen.force.FlowField
     
    -
    setForceArea(float[][], int, int, float, float) - Method in class teilchen.force.flowfield.FlowField
    +
    setForceArea(float[][], int, int, float, float) - Method in class teilchen.force.FlowField
     
    setIdentity() - Method in class teilchen.util.Matrix3f
     
    @@ -156,11 +156,11 @@

    S

     
    setParticleClass(Class<T>) - Method in class teilchen.util.ParticleTrail
     
    -
    setPosition(PVector) - Method in class teilchen.force.flowfield.FlowFieldForceMOUSE
    +
    setPosition(PVector) - Method in class teilchen.force.FlowFieldForceMOUSE
     
    -
    setPosition(PVector) - Method in class teilchen.force.vectorfield.VectorField
    +
    setPosition(PVector) - Method in class teilchen.force.VectorField
     
    -
    setPosition(PVector) - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    setPosition(PVector) - Method in class teilchen.force.VectorFieldUnit
     
    setPositionRef(PVector) - Method in class teilchen.BasicParticle
     
    @@ -186,9 +186,9 @@

    S

     
    setRotationIdentity() - Method in class teilchen.util.TransformMatrix4f
     
    -
    setScale(PVector) - Method in class teilchen.force.vectorfield.VectorField
    +
    setScale(PVector) - Method in class teilchen.force.VectorField
     
    -
    setScale(PVector) - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    setScale(PVector) - Method in class teilchen.force.VectorFieldUnit
     
    setScale(PVector) - Method in class teilchen.util.Matrix3f
     
    @@ -222,9 +222,9 @@

    S

     
    ShortLivedParticle() - Constructor for class teilchen.ShortLivedParticle
     
    -
    showHair - Variable in class teilchen.force.flowfield.FlowField
    +
    showHair - Variable in class teilchen.force.FlowField
     
    -
    showVelocity - Variable in class teilchen.force.flowfield.FlowField
    +
    showVelocity - Variable in class teilchen.force.FlowField
     
    size() - Method in class teilchen.cubicle.CubicleAtom
     
    @@ -316,17 +316,13 @@

    S

     
    strength(float) - Method in class teilchen.force.Attractor
     
    -
    strength - Variable in class teilchen.force.flowfield.FlowFieldForce
    +
    strength - Variable in class teilchen.force.FlowFieldForce
     
    strength() - Method in class teilchen.force.Spring
    -
    -
    spring constant.
    -
    +
     
    strength(float) - Method in class teilchen.force.Spring
    -
    -
    spring constant.
    -
    -
    strength - Variable in class teilchen.force.vectorfield.VectorField
    +
     
    +
    strength - Variable in class teilchen.force.VectorField
     
    sub(Matrix3f, Matrix3f) - Method in class teilchen.util.Matrix3f
     
    diff --git a/processing-library/teilchen/reference/index-files/index-17.html b/processing-library/teilchen/reference/index-files/index-17.html index 7727462..72a214f 100644 --- a/processing-library/teilchen/reference/index-files/index-17.html +++ b/processing-library/teilchen/reference/index-files/index-17.html @@ -2,9 +2,9 @@ - + T-Index - + @@ -102,10 +102,6 @@

    T

     
    teilchen.force - package teilchen.force
     
    -
    teilchen.force.flowfield - package teilchen.force.flowfield
    -
     
    -
    teilchen.force.vectorfield - package teilchen.force.vectorfield
    -
     
    teilchen.integration - package teilchen.integration
     
    teilchen.util - package teilchen.util
    @@ -138,7 +134,7 @@

    T

     
    transform() - Method in class teilchen.cubicle.CubicleWorld
     
    -
    transform() - Method in class teilchen.force.flowfield.FlowField
    +
    transform() - Method in class teilchen.force.FlowField
     
    transform(PVector) - Method in class teilchen.util.Matrix3f
     
    diff --git a/processing-library/teilchen/reference/index-files/index-18.html b/processing-library/teilchen/reference/index-files/index-18.html index a2b785f..cdae20c 100644 --- a/processing-library/teilchen/reference/index-files/index-18.html +++ b/processing-library/teilchen/reference/index-files/index-18.html @@ -2,9 +2,9 @@ - + U-Index - + @@ -72,7 +72,7 @@

    U

    -
    u() - Method in class teilchen.force.flowfield.FlowField
    +
    u() - Method in class teilchen.force.FlowField
     
    u - Variable in class teilchen.util.Intersection.IntersectionResult
     
    diff --git a/processing-library/teilchen/reference/index-files/index-19.html b/processing-library/teilchen/reference/index-files/index-19.html index fdadbc6..286cd33 100644 --- a/processing-library/teilchen/reference/index-files/index-19.html +++ b/processing-library/teilchen/reference/index-files/index-19.html @@ -2,9 +2,9 @@ - + V-Index - + @@ -72,7 +72,7 @@

    V

    -
    v() - Method in class teilchen.force.flowfield.FlowField
    +
    v() - Method in class teilchen.force.FlowField
     
    v - Variable in class teilchen.util.Intersection.IntersectionResult
     
    @@ -123,33 +123,33 @@

    V

     
    vectorB - Variable in class teilchen.util.Plane3f
     
    -
    VectorField - Class in teilchen.force.vectorfield
    +
    VectorField - Class in teilchen.force
     
    -
    VectorField(VectorFieldGenerator) - Constructor for class teilchen.force.vectorfield.VectorField
    +
    VectorField(VectorFieldGenerator) - Constructor for class teilchen.force.VectorField
     
    -
    VectorFieldGenerator - Interface in teilchen.force.vectorfield
    +
    VectorFieldGenerator - Interface in teilchen.force
     
    -
    VectorFieldGeneratorAVERAGEUNITS - Class in teilchen.force.vectorfield
    +
    VectorFieldGeneratorAVERAGEUNITS - Class in teilchen.force
     
    -
    VectorFieldGeneratorAVERAGEUNITS(int, int, int, PVector[], PVector[]) - Constructor for class teilchen.force.vectorfield.VectorFieldGeneratorAVERAGEUNITS
    +
    VectorFieldGeneratorAVERAGEUNITS(int, int, int, PVector[], PVector[]) - Constructor for class teilchen.force.VectorFieldGeneratorAVERAGEUNITS
     
    -
    VectorFieldGeneratorRANDOM - Class in teilchen.force.vectorfield
    +
    VectorFieldGeneratorRANDOM - Class in teilchen.force
     
    -
    VectorFieldGeneratorRANDOM(int, int, int) - Constructor for class teilchen.force.vectorfield.VectorFieldGeneratorRANDOM
    +
    VectorFieldGeneratorRANDOM(int, int, int) - Constructor for class teilchen.force.VectorFieldGeneratorRANDOM
     
    VectorfieldParticle - Class in teilchen
     
    VectorfieldParticle() - Constructor for class teilchen.VectorfieldParticle
     
    -
    VectorFieldUnit - Class in teilchen.force.vectorfield
    +
    VectorFieldUnit - Class in teilchen.force
     
    -
    VectorFieldUnit(PVector, PVector, PVector) - Constructor for class teilchen.force.vectorfield.VectorFieldUnit
    +
    VectorFieldUnit(PVector, PVector, PVector) - Constructor for class teilchen.force.VectorFieldUnit
     
    velocity() - Method in class teilchen.BasicParticle
     
    velocity() - Method in interface teilchen.Particle
     
    -
    velocityBrushSize - Variable in class teilchen.force.flowfield.FlowField
    +
    velocityBrushSize - Variable in class teilchen.force.FlowField
     
    Verhalten - Interface in teilchen.behavior
     
    diff --git a/processing-library/teilchen/reference/index-files/index-2.html b/processing-library/teilchen/reference/index-files/index-2.html index c84ad67..96a4569 100644 --- a/processing-library/teilchen/reference/index-files/index-2.html +++ b/processing-library/teilchen/reference/index-files/index-2.html @@ -2,9 +2,9 @@ - + B-Index - + diff --git a/processing-library/teilchen/reference/index-files/index-20.html b/processing-library/teilchen/reference/index-files/index-20.html index 8db5bf4..5fbc96e 100644 --- a/processing-library/teilchen/reference/index-files/index-20.html +++ b/processing-library/teilchen/reference/index-files/index-20.html @@ -2,9 +2,9 @@ - + W-Index - + diff --git a/processing-library/teilchen/reference/index-files/index-21.html b/processing-library/teilchen/reference/index-files/index-21.html index 98b6bdb..37f2653 100644 --- a/processing-library/teilchen/reference/index-files/index-21.html +++ b/processing-library/teilchen/reference/index-files/index-21.html @@ -2,9 +2,9 @@ - + X-Index - + diff --git a/processing-library/teilchen/reference/index-files/index-22.html b/processing-library/teilchen/reference/index-files/index-22.html index 8e712b2..e2e546b 100644 --- a/processing-library/teilchen/reference/index-files/index-22.html +++ b/processing-library/teilchen/reference/index-files/index-22.html @@ -2,9 +2,9 @@ - + Y-Index - + diff --git a/processing-library/teilchen/reference/index-files/index-23.html b/processing-library/teilchen/reference/index-files/index-23.html index adb9cc2..5a5c69c 100644 --- a/processing-library/teilchen/reference/index-files/index-23.html +++ b/processing-library/teilchen/reference/index-files/index-23.html @@ -2,9 +2,9 @@ - + Z-Index - + diff --git a/processing-library/teilchen/reference/index-files/index-3.html b/processing-library/teilchen/reference/index-files/index-3.html index 8c0306a..2a205ab 100644 --- a/processing-library/teilchen/reference/index-files/index-3.html +++ b/processing-library/teilchen/reference/index-files/index-3.html @@ -2,9 +2,9 @@ - + C-Index - + @@ -78,9 +78,9 @@

    C

     
    c - Variable in class teilchen.util.StableStickQuad
     
    -
    calculateDensity - Variable in class teilchen.force.flowfield.FlowField
    +
    calculateDensity - Variable in class teilchen.force.FlowField
     
    -
    calculateDensity() - Method in class teilchen.force.flowfield.FlowField
    +
    calculateDensity() - Method in class teilchen.force.FlowField
     
    calculateDerivatives(List<Particle>, List<Derivate3f>) - Static method in class teilchen.integration.IntegrationUtil
     
    @@ -96,9 +96,9 @@

    C

     
    calculateReflectionVector(Particle, PVector) - Static method in class teilchen.util.Util
     
    -
    calculateVelocity - Variable in class teilchen.force.flowfield.FlowField
    +
    calculateVelocity - Variable in class teilchen.force.FlowField
     
    -
    calculateVelocity() - Method in class teilchen.force.flowfield.FlowField
    +
    calculateVelocity() - Method in class teilchen.force.FlowField
     
    cd - Variable in class teilchen.util.StableSpringQuad
     
    @@ -181,12 +181,6 @@

    C

     
    compareTo(Vector3i) - Method in class teilchen.util.Vector3i
     
    -
    condition() - Method in class teilchen.ConditionalParticle
    -
     
    -
    ConditionalParticle - Class in teilchen
    -
     
    -
    ConditionalParticle() - Constructor for class teilchen.ConditionalParticle
    -
     
    constrain_iterations_per_steps - Variable in class teilchen.Physics
     
    constraints() - Method in class teilchen.Physics
    diff --git a/processing-library/teilchen/reference/index-files/index-4.html b/processing-library/teilchen/reference/index-files/index-4.html index f6dfb42..eff6112 100644 --- a/processing-library/teilchen/reference/index-files/index-4.html +++ b/processing-library/teilchen/reference/index-files/index-4.html @@ -2,9 +2,9 @@ - + D-Index - + @@ -100,21 +100,19 @@

    D

     
    data() - Method in class teilchen.cubicle.CubicleAtom
     
    -
    data() - Method in class teilchen.force.vectorfield.VectorField
    +
    data() - Method in class teilchen.force.VectorField
     
    -
    data() - Method in interface teilchen.force.vectorfield.VectorFieldGenerator
    +
    data() - Method in interface teilchen.force.VectorFieldGenerator
     
    -
    data() - Method in class teilchen.force.vectorfield.VectorFieldGeneratorAVERAGEUNITS
    +
    data() - Method in class teilchen.force.VectorFieldGeneratorAVERAGEUNITS
     
    -
    data() - Method in class teilchen.force.vectorfield.VectorFieldGeneratorRANDOM
    +
    data() - Method in class teilchen.force.VectorFieldGeneratorRANDOM
     
    dead() - Method in class teilchen.BasicParticle
     
    -
    dead() - Method in class teilchen.ConditionalParticle
    -
     
    dead() - Method in class teilchen.force.Attractor
     
    -
    dead() - Method in class teilchen.force.flowfield.FlowField
    +
    dead() - Method in class teilchen.force.FlowField
     
    dead() - Method in class teilchen.force.Gravity
     
    @@ -132,17 +130,19 @@

    D

     
    dead() - Method in class teilchen.force.TriangleDeflector
     
    -
    dead() - Method in class teilchen.force.vectorfield.VectorField
    +
    dead() - Method in class teilchen.force.VectorField
     
    dead() - Method in class teilchen.force.ViscousDrag
     
    +
    dead() - Method in class teilchen.MortalParticle
    +
     
    dead() - Method in interface teilchen.Particle
     
    dead() - Method in class teilchen.ShortLivedParticle
     
    DEBUG_VIEW - Variable in class teilchen.constraint.LineIntersectionConstraint
     
    -
    deltatime - Variable in class teilchen.force.flowfield.FlowField
    +
    deltatime - Variable in class teilchen.force.FlowField
     
    Derivate3f - Class in teilchen.integration
     
    diff --git a/processing-library/teilchen/reference/index-files/index-5.html b/processing-library/teilchen/reference/index-files/index-5.html index e72aad3..31be04c 100644 --- a/processing-library/teilchen/reference/index-files/index-5.html +++ b/processing-library/teilchen/reference/index-files/index-5.html @@ -2,9 +2,9 @@ - + E-Index - + diff --git a/processing-library/teilchen/reference/index-files/index-6.html b/processing-library/teilchen/reference/index-files/index-6.html index 9ef220d..7ca11d3 100644 --- a/processing-library/teilchen/reference/index-files/index-6.html +++ b/processing-library/teilchen/reference/index-files/index-6.html @@ -2,9 +2,9 @@ - + F-Index - + @@ -90,19 +90,19 @@

    F

     
    FLOAT(float, float) - Static method in class teilchen.util.Random
     
    -
    FlowField - Class in teilchen.force.flowfield
    +
    FlowField - Class in teilchen.force
     
    -
    FlowField() - Constructor for class teilchen.force.flowfield.FlowField
    +
    FlowField() - Constructor for class teilchen.force.FlowField
     
    -
    FlowField(int, int, PVector) - Constructor for class teilchen.force.flowfield.FlowField
    +
    FlowField(int, int, PVector) - Constructor for class teilchen.force.FlowField
     
    -
    FlowFieldForce - Class in teilchen.force.flowfield
    +
    FlowFieldForce - Class in teilchen.force
     
    -
    FlowFieldForce() - Constructor for class teilchen.force.flowfield.FlowFieldForce
    +
    FlowFieldForce() - Constructor for class teilchen.force.FlowFieldForce
     
    -
    FlowFieldForceMOUSE - Class in teilchen.force.flowfield
    +
    FlowFieldForceMOUSE - Class in teilchen.force
     
    -
    FlowFieldForceMOUSE() - Constructor for class teilchen.force.flowfield.FlowFieldForceMOUSE
    +
    FlowFieldForceMOUSE() - Constructor for class teilchen.force.FlowFieldForceMOUSE
     
    force() - Method in class teilchen.BasicParticle
     
    @@ -132,13 +132,13 @@

    F

     
    force() - Method in interface teilchen.Particle
     
    -
    forces() - Method in class teilchen.force.flowfield.FlowField
    +
    forces() - Method in class teilchen.force.FlowField
     
    forces() - Method in class teilchen.Physics
     
    forces(int) - Method in class teilchen.Physics
     
    -
    forceScale - Variable in class teilchen.force.flowfield.FlowField
    +
    forceScale - Variable in class teilchen.force.FlowField
     
    fragments() - Method in class teilchen.util.ParticleTrail
     
    diff --git a/processing-library/teilchen/reference/index-files/index-7.html b/processing-library/teilchen/reference/index-files/index-7.html index e72c3d8..ba2fb1d 100644 --- a/processing-library/teilchen/reference/index-files/index-7.html +++ b/processing-library/teilchen/reference/index-files/index-7.html @@ -2,9 +2,9 @@ - + G-Index - + @@ -72,7 +72,7 @@

    G

    -
    getAcceleration() - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    getAcceleration() - Method in class teilchen.force.VectorFieldUnit
     
    getAtom(int, int, int) - Method in class teilchen.cubicle.CubicleWorld
     
    @@ -89,7 +89,7 @@

    G

    getFloat() - Method in class teilchen.util.Random
     
    -
    getForce(PVector) - Method in class teilchen.force.flowfield.FlowField
    +
    getForce(PVector) - Method in class teilchen.force.FlowField
     
    getInt(int, int) - Method in class teilchen.util.Random
    @@ -113,13 +113,13 @@

    G

     
    getOffWorldAtom() - Method in class teilchen.cubicle.CubicleWorld
     
    -
    getPosition() - Method in class teilchen.force.vectorfield.VectorField
    +
    getPosition() - Method in class teilchen.force.VectorField
     
    -
    getPosition() - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    getPosition() - Method in class teilchen.force.VectorFieldUnit
     
    -
    getScale() - Method in class teilchen.force.vectorfield.VectorField
    +
    getScale() - Method in class teilchen.force.VectorField
     
    -
    getScale() - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    getScale() - Method in class teilchen.force.VectorFieldUnit
     
    getVector3f(float, float) - Method in class teilchen.util.Random
     
    diff --git a/processing-library/teilchen/reference/index-files/index-8.html b/processing-library/teilchen/reference/index-files/index-8.html index f520331..3824478 100644 --- a/processing-library/teilchen/reference/index-files/index-8.html +++ b/processing-library/teilchen/reference/index-files/index-8.html @@ -2,9 +2,9 @@ - + H-Index - + diff --git a/processing-library/teilchen/reference/index-files/index-9.html b/processing-library/teilchen/reference/index-files/index-9.html index d11c4f2..5de760c 100644 --- a/processing-library/teilchen/reference/index-files/index-9.html +++ b/processing-library/teilchen/reference/index-files/index-9.html @@ -2,9 +2,9 @@ - + I-Index - + @@ -145,7 +145,9 @@

    I

    entities can be temporarily removed from the process of being updated by the world.
    -
    isInside(PVector) - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    isDead() - Method in class teilchen.MortalParticle
    +
     
    +
    isInside(PVector) - Method in class teilchen.force.VectorFieldUnit
     
    isNaN(PVector) - Static method in class teilchen.util.Util
     
    diff --git a/processing-library/teilchen/reference/index.html b/processing-library/teilchen/reference/index.html index 4dc570d..364ed86 100644 --- a/processing-library/teilchen/reference/index.html +++ b/processing-library/teilchen/reference/index.html @@ -2,7 +2,7 @@ - + Generated Documentation (Untitled) @@ -18,8 +18,6 @@

    Packages

  • teilchen.constraint
  • teilchen.cubicle
  • teilchen.force
  • -
  • teilchen.force.flowfield
  • -
  • teilchen.force.vectorfield
  • teilchen.integration
  • teilchen.util
  • diff --git a/processing-library/teilchen/reference/overview-summary.html b/processing-library/teilchen/reference/overview-summary.html index e0e4970..8d6de66 100644 --- a/processing-library/teilchen/reference/overview-summary.html +++ b/processing-library/teilchen/reference/overview-summary.html @@ -2,9 +2,9 @@ - + Overview - + @@ -96,14 +96,6 @@   -teilchen.force.flowfield -  - - -teilchen.force.vectorfield -  - - teilchen.integration   diff --git a/processing-library/teilchen/reference/overview-tree.html b/processing-library/teilchen/reference/overview-tree.html index 6f14905..939a59c 100644 --- a/processing-library/teilchen/reference/overview-tree.html +++ b/processing-library/teilchen/reference/overview-tree.html @@ -2,9 +2,9 @@ - + Class Hierarchy - + @@ -76,8 +76,6 @@

    Hierarchy For All Packages

  • teilchen.constraint,
  • teilchen.cubicle,
  • teilchen.force,
  • -
  • teilchen.force.flowfield,
  • -
  • teilchen.force.vectorfield,
  • teilchen.integration,
  • teilchen.util
  • @@ -98,8 +96,8 @@

    Class Hierarchy

  • teilchen.BasicParticle (implements teilchen.Particle, java.io.Serializable) @@ -115,10 +113,10 @@

    Class Hierarchy

  • teilchen.util.DrawLib
  • teilchen.integration.Euler (implements teilchen.integration.IIntegrator)
  • teilchen.behavior.Flee (implements teilchen.behavior.IBehavior, teilchen.behavior.Verhalten)
  • -
  • teilchen.force.flowfield.FlowField (implements teilchen.force.IForce)
  • -
  • teilchen.force.flowfield.FlowFieldForce +
  • teilchen.force.FlowField (implements teilchen.force.IForce)
  • +
  • teilchen.force.FlowFieldForce
  • teilchen.force.Gravity (implements teilchen.force.IForce)
  • @@ -176,10 +174,10 @@

    Class Hierarchy

  • teilchen.behavior.Util.ProximityStructure
  • teilchen.util.Vector3i (implements java.lang.Comparable<T>, java.io.Serializable)
  • teilchen.util.Vector4f (implements java.io.Serializable)
  • -
  • teilchen.force.vectorfield.VectorField (implements teilchen.force.IForce)
  • -
  • teilchen.force.vectorfield.VectorFieldGeneratorAVERAGEUNITS (implements teilchen.force.vectorfield.VectorFieldGenerator)
  • -
  • teilchen.force.vectorfield.VectorFieldGeneratorRANDOM (implements teilchen.force.vectorfield.VectorFieldGenerator)
  • -
  • teilchen.force.vectorfield.VectorFieldUnit
  • +
  • teilchen.force.VectorField (implements teilchen.force.IForce)
  • +
  • teilchen.force.VectorFieldGeneratorAVERAGEUNITS (implements teilchen.force.VectorFieldGenerator)
  • +
  • teilchen.force.VectorFieldGeneratorRANDOM (implements teilchen.force.VectorFieldGenerator)
  • +
  • teilchen.force.VectorFieldUnit
  • teilchen.integration.Verlet (implements teilchen.integration.IIntegrator)
  • teilchen.force.ViscousDrag (implements teilchen.force.IForce)
  • teilchen.behavior.Wander (implements teilchen.behavior.IBehavior)
  • @@ -210,7 +208,7 @@

    Interface Hierarchy

    -
  • teilchen.force.vectorfield.VectorFieldGenerator
  • +
  • teilchen.force.VectorFieldGenerator
  • Enum Hierarchy

    Direct Known Subclasses:
    -
    BehaviorParticle, ConditionalParticle, CubicleParticle, ShortLivedParticle, VectorfieldParticle
    +
    BehaviorParticle, CubicleParticle, MortalParticle, ShortLivedParticle, VectorfieldParticle


    diff --git a/processing-library/teilchen/reference/teilchen/BehaviorParticle.html b/processing-library/teilchen/reference/teilchen/BehaviorParticle.html index 437acaf..47c4d43 100644 --- a/processing-library/teilchen/reference/teilchen/BehaviorParticle.html +++ b/processing-library/teilchen/reference/teilchen/BehaviorParticle.html @@ -2,9 +2,9 @@ - + BehaviorParticle - + @@ -48,7 +48,7 @@
    All Known Implementing Classes:
    -
    BasicParticle, BehaviorParticle, ConditionalParticle, CubicleParticle, Packing.PackingEntity, ShortLivedParticle, VectorfieldParticle
    +
    BasicParticle, BehaviorParticle, CubicleParticle, MortalParticle, Packing.PackingEntity, ShortLivedParticle, VectorfieldParticle


    diff --git a/processing-library/teilchen/reference/teilchen/util/StableSpringQuad.html b/processing-library/teilchen/reference/teilchen/util/StableSpringQuad.html index 4f77728..ec0ccc1 100644 --- a/processing-library/teilchen/reference/teilchen/util/StableSpringQuad.html +++ b/processing-library/teilchen/reference/teilchen/util/StableSpringQuad.html @@ -2,9 +2,9 @@ - + StableSpringQuad - + diff --git a/processing-library/teilchen/reference/teilchen/util/StableStickQuad.html b/processing-library/teilchen/reference/teilchen/util/StableStickQuad.html index 078ae2c..4657d4d 100644 --- a/processing-library/teilchen/reference/teilchen/util/StableStickQuad.html +++ b/processing-library/teilchen/reference/teilchen/util/StableStickQuad.html @@ -2,9 +2,9 @@ - + StableStickQuad - + diff --git a/processing-library/teilchen/reference/teilchen/util/StickMan.html b/processing-library/teilchen/reference/teilchen/util/StickMan.html index a99b27a..9619f46 100644 --- a/processing-library/teilchen/reference/teilchen/util/StickMan.html +++ b/processing-library/teilchen/reference/teilchen/util/StickMan.html @@ -2,9 +2,9 @@ - + StickMan - + diff --git a/processing-library/teilchen/reference/teilchen/util/TransformMatrix4f.html b/processing-library/teilchen/reference/teilchen/util/TransformMatrix4f.html index 83af6ae..19e5ddb 100644 --- a/processing-library/teilchen/reference/teilchen/util/TransformMatrix4f.html +++ b/processing-library/teilchen/reference/teilchen/util/TransformMatrix4f.html @@ -2,9 +2,9 @@ - + TransformMatrix4f - + diff --git a/processing-library/teilchen/reference/teilchen/util/Util.html b/processing-library/teilchen/reference/teilchen/util/Util.html index 85d327b..184f4a7 100644 --- a/processing-library/teilchen/reference/teilchen/util/Util.html +++ b/processing-library/teilchen/reference/teilchen/util/Util.html @@ -2,9 +2,9 @@ - + Util - + diff --git a/processing-library/teilchen/reference/teilchen/util/Vector3i.html b/processing-library/teilchen/reference/teilchen/util/Vector3i.html index 5067f21..e5dc819 100644 --- a/processing-library/teilchen/reference/teilchen/util/Vector3i.html +++ b/processing-library/teilchen/reference/teilchen/util/Vector3i.html @@ -2,9 +2,9 @@ - + Vector3i - + diff --git a/processing-library/teilchen/reference/teilchen/util/Vector4f.html b/processing-library/teilchen/reference/teilchen/util/Vector4f.html index 0bd589d..96682c8 100644 --- a/processing-library/teilchen/reference/teilchen/util/Vector4f.html +++ b/processing-library/teilchen/reference/teilchen/util/Vector4f.html @@ -2,9 +2,9 @@ - + Vector4f - + diff --git a/processing-library/teilchen/reference/teilchen/util/WorldAxisAlignedBoundingBox.html b/processing-library/teilchen/reference/teilchen/util/WorldAxisAlignedBoundingBox.html index c63f0dd..163b2ba 100644 --- a/processing-library/teilchen/reference/teilchen/util/WorldAxisAlignedBoundingBox.html +++ b/processing-library/teilchen/reference/teilchen/util/WorldAxisAlignedBoundingBox.html @@ -2,9 +2,9 @@ - + WorldAxisAlignedBoundingBox - + diff --git a/processing-library/teilchen/reference/teilchen/util/package-frame.html b/processing-library/teilchen/reference/teilchen/util/package-frame.html index 7330f3e..8560f69 100644 --- a/processing-library/teilchen/reference/teilchen/util/package-frame.html +++ b/processing-library/teilchen/reference/teilchen/util/package-frame.html @@ -2,9 +2,9 @@ - + teilchen.util - + diff --git a/processing-library/teilchen/reference/teilchen/util/package-summary.html b/processing-library/teilchen/reference/teilchen/util/package-summary.html index 106432b..68b66ea 100644 --- a/processing-library/teilchen/reference/teilchen/util/package-summary.html +++ b/processing-library/teilchen/reference/teilchen/util/package-summary.html @@ -2,9 +2,9 @@ - + teilchen.util - + diff --git a/processing-library/teilchen/reference/teilchen/util/package-tree.html b/processing-library/teilchen/reference/teilchen/util/package-tree.html index e317c27..c2cdea1 100644 --- a/processing-library/teilchen/reference/teilchen/util/package-tree.html +++ b/processing-library/teilchen/reference/teilchen/util/package-tree.html @@ -2,9 +2,9 @@ - + teilchen.util Class Hierarchy - + diff --git a/processing-library/teilchen/src/teilchen/BasicParticle.java b/processing-library/teilchen/src/teilchen/BasicParticle.java index dc4cdca..9d0f10a 100755 --- a/processing-library/teilchen/src/teilchen/BasicParticle.java +++ b/processing-library/teilchen/src/teilchen/BasicParticle.java @@ -19,36 +19,27 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; -import java.io.Serializable; import processing.core.PVector; -public class BasicParticle - implements Particle, Serializable { - - private boolean mFixed; - - private float mAge; - - private float mMass; +import java.io.Serializable; - private PVector mPosition; +public class BasicParticle implements Particle, Serializable { + private static final long serialVersionUID = 3737917975116369338L; private final PVector mOldPosition; - private final PVector mVelocity; - private final PVector mForce; - + private boolean mFixed; + private float mAge; + private float mMass; + private PVector mPosition; private boolean mTagged; - private boolean mStill; - private float mRadius; - private static final long serialVersionUID = 3737917975116369338L; - public BasicParticle() { mPosition = new PVector(); mOldPosition = new PVector(); @@ -86,10 +77,6 @@ public void mass(float pMass) { mMass = pMass; } - public PVector position() { - return mPosition; - } - public PVector old_position() { return mOldPosition; } @@ -110,9 +97,6 @@ public boolean dead() { return false; } - public void accumulateInnerForce(final float pDeltaTime) { - } - public boolean tagged() { return mTagged; } @@ -121,19 +105,26 @@ public void tag(boolean pTag) { mTagged = pTag; } - public boolean still() { - return mStill; - } - - public void still(boolean pStill) { - mStill = pStill; + public void accumulateInnerForce(final float pDeltaTime) { } public float radius() { return mRadius; } + public PVector position() { + return mPosition; + } + public void radius(float pRadius) { mRadius = pRadius; } + + public boolean still() { + return mStill; + } + + public void still(boolean pStill) { + mStill = pStill; + } } diff --git a/processing-library/teilchen/src/teilchen/BehaviorParticle.java b/processing-library/teilchen/src/teilchen/BehaviorParticle.java index 522b31c..31d56fb 100755 --- a/processing-library/teilchen/src/teilchen/BehaviorParticle.java +++ b/processing-library/teilchen/src/teilchen/BehaviorParticle.java @@ -61,8 +61,8 @@ public float maximumInnerForce() { return mMaximumInnerForce; } - public void maximumInnerForce(float theForce) { - mMaximumInnerForce = theForce; + public void maximumInnerForce(float pForce) { + mMaximumInnerForce = pForce; } public ArrayList behaviors() { diff --git a/processing-library/teilchen/src/teilchen/IBehaviorParticle.java b/processing-library/teilchen/src/teilchen/IBehaviorParticle.java index 2c3252c..3a23265 100755 --- a/processing-library/teilchen/src/teilchen/IBehaviorParticle.java +++ b/processing-library/teilchen/src/teilchen/IBehaviorParticle.java @@ -28,7 +28,7 @@ public interface IBehaviorParticle float maximumInnerForce(); - void maximumInnerForce(float theForce); + void maximumInnerForce(float pForce); ArrayList behaviors(); } diff --git a/src/teilchen/ConditionalParticle.java b/processing-library/teilchen/src/teilchen/MortalParticle.java similarity index 86% rename from src/teilchen/ConditionalParticle.java rename to processing-library/teilchen/src/teilchen/MortalParticle.java index c10d634..8adbbaa 100755 --- a/src/teilchen/ConditionalParticle.java +++ b/processing-library/teilchen/src/teilchen/MortalParticle.java @@ -19,14 +19,14 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; -public abstract class ConditionalParticle - extends BasicParticle { +public abstract class MortalParticle extends BasicParticle { public boolean dead() { - return !condition(); + return isDead(); } - public abstract boolean condition(); + public abstract boolean isDead(); } diff --git a/processing-library/teilchen/src/teilchen/Particle.java b/processing-library/teilchen/src/teilchen/Particle.java index 2b91ef2..28cfdec 100755 --- a/processing-library/teilchen/src/teilchen/Particle.java +++ b/processing-library/teilchen/src/teilchen/Particle.java @@ -19,6 +19,7 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; import processing.core.PVector; @@ -39,8 +40,6 @@ public interface Particle void mass(float pMass); - PVector position(); - PVector old_position(); void setPositionRef(PVector pPosition); @@ -59,6 +58,8 @@ public interface Particle float radius(); + PVector position(); + void radius(float pRadius); boolean still(); diff --git a/processing-library/teilchen/src/teilchen/Physics.java b/processing-library/teilchen/src/teilchen/Physics.java index 0335fae..c6b32cb 100755 --- a/processing-library/teilchen/src/teilchen/Physics.java +++ b/processing-library/teilchen/src/teilchen/Physics.java @@ -62,30 +62,30 @@ public void add(Particle theParticle) { mParticles.add(theParticle); } - public void add(Collection theParticles) { - mParticles.addAll(theParticles); + public void add(Collection pParticles) { + mParticles.addAll(pParticles); } public void remove(Particle theParticle) { mParticles.remove(theParticle); } - public void remove(Collection theParticles) { + public void remove(Collection pParticles) { - mParticles.removeAll(theParticles); + mParticles.removeAll(pParticles); } public ArrayList particles() { return mParticles; } - public Particle particles(final int theIndex) { - return mParticles.get(theIndex); + public Particle particles(final int pIndex) { + return mParticles.get(pIndex); } - public BasicParticle makeParticle(final PVector thePosition) { + public BasicParticle makeParticle(final PVector pPosition) { BasicParticle myParticle = makeParticle(); - myParticle.setPositionRef(thePosition); + myParticle.setPositionRef(pPosition); myParticle.old_position().set(myParticle.position()); return myParticle; } @@ -126,10 +126,10 @@ public BasicParticle makeParticle(final PVector thePosition, final float pMass) return myParticle; } - public T makeParticle(Class theParticleClass) { + public T makeParticle(Class pParticleClass) { T myParticle; try { - myParticle = theParticleClass.newInstance(); + myParticle = pParticleClass.newInstance(); mParticles.add(myParticle); } catch (Exception ex) { ex.printStackTrace(); @@ -148,14 +148,15 @@ public void removeTags() { /* forces */ public void add(IForce theForce) { if (theForce instanceof ViscousDrag && mIntegrator instanceof Verlet) { - System.err.println("### WARNING / 'viscous drag' might have no effect with 'verlet' integration. use 'Verlet" + "" + - ".damping" + "(float theDamping)' instead."); + System.err.println( + "### WARNING / 'viscous drag' might have no effect with 'verlet' integration. use 'Verlet" + "" + + ".damping" + "(float theDamping)' instead."); } mForces.add(theForce); } - public void addForces(final ArrayList theForces) { - mForces.addAll(theForces); + public void addForces(final ArrayList pForces) { + mForces.addAll(pForces); } public void remove(IForce theForce) { @@ -191,10 +192,10 @@ public void applyForces(final float theDeltaTime) { } } - public T makeForce(Class theForceClass) { + public T makeForce(Class pForceClass) { T myForce; try { - myForce = theForceClass.newInstance(); + myForce = pForceClass.newInstance(); mForces.add(myForce); } catch (Exception ex) { myForce = null; @@ -202,81 +203,84 @@ public T makeForce(Class theForceClass) { return myForce; } - public Spring makeSpring(final Particle theA, final Particle theB) { - Spring mySpring = new Spring(theA, theB); + public Spring makeSpring(final Particle pA, final Particle pB) { + Spring mySpring = new Spring(pA, pB); mForces.add(mySpring); return mySpring; } - public Spring makeSpring(final Particle theA, final Particle theB, final float theRestLength) { - Spring mySpring = new Spring(theA, theB, theRestLength); + public Spring makeSpring(final Particle pA, final Particle pB, final float pRestLength) { + Spring mySpring = new Spring(pA, pB, pRestLength); mForces.add(mySpring); return mySpring; } - public Spring makeSpring(final Particle theA, final Particle theB, final float theSpringConstant, final float theSpringDamping) { - Spring mySpring = new Spring(theA, theB, theSpringConstant, theSpringDamping); + public Spring makeSpring(final Particle pA, + final Particle pB, + final float pSpringConstant, + final float pSpringDamping) { + Spring mySpring = new Spring(pA, pB, pSpringConstant, pSpringDamping); mForces.add(mySpring); return mySpring; } - public Spring makeSpring(final Particle theA, - final Particle theB, - final float theSpringConstant, - final float theSpringDamping, - final float theRestLength) { - Spring mySpring = new Spring(theA, theB, theSpringConstant, theSpringDamping, theRestLength); + public Spring makeSpring(final Particle pA, + final Particle pB, + final float pSpringConstant, + final float pSpringDamping, + final float pRestLength) { + Spring mySpring = new Spring(pA, pB, pSpringConstant, pSpringDamping, pRestLength); mForces.add(mySpring); return mySpring; } /* constraints */ - public void add(final IConstraint theConstraint) { - mConstraints.add(theConstraint); + public void add(final IConstraint pConstraint) { + mConstraints.add(pConstraint); } - public void addConstraints(final ArrayList theConstraints) { - mConstraints.addAll(theConstraints); + public void addConstraints(final ArrayList pConstraints) { + mConstraints.addAll(pConstraints); } - public void remove(final IConstraint theConstraint) { - mConstraints.remove(theConstraint); + public void remove(final IConstraint pConstraint) { + mConstraints.remove(pConstraint); } public ArrayList constraints() { return mConstraints; } - public IConstraint constraints(final int theIndex) { - return mConstraints.get(theIndex); + public IConstraint constraints(final int pIndex) { + return mConstraints.get(pIndex); } /* integration */ - public void setIntegratorRef(IIntegrator theIntegrator) { - mIntegrator = theIntegrator; + public void setIntegratorRef(IIntegrator pIntegrator) { + mIntegrator = pIntegrator; } public IIntegrator getIntegrator() { return mIntegrator; } - public void loop(final float theDeltaTime, final int theIterations) { - for (int i = 0; i < theIterations; i++) { - step(theDeltaTime / (float) theIterations); + public void loop(final float theDeltaTime, final int pIterations) { + for (int i = 0; i < pIterations; i++) { + step(theDeltaTime / (float) pIterations); } } - public void step(final float theDeltaTime) { + public void step(final float pDeltaTime) { handleForces(); - integrate(theDeltaTime); - advance(theDeltaTime); + integrate(pDeltaTime); + advance(pDeltaTime); handleConstraints(); - post(theDeltaTime); + post(pDeltaTime); } - protected synchronized void integrate(float theDeltaTime) { + protected synchronized void integrate(float pDeltaTime) { for (int j = 0; j < integrations_per_steps; j++) { - mIntegrator.step(theDeltaTime / integrations_per_steps, this); + mIntegrator.step(pDeltaTime / integrations_per_steps, this); } } @@ -302,7 +306,7 @@ protected synchronized void handleConstraints() { } } - protected synchronized void advance(float theDeltaTime) { + protected synchronized void advance(float pDeltaTime) { synchronized (mParticles) { final Iterator i = mParticles.iterator(); while (i.hasNext()) { @@ -310,7 +314,7 @@ protected synchronized void advance(float theDeltaTime) { /* clear force */ mParticle.force().set(0, 0, 0); /* age particle */ - mParticle.age(mParticle.age() + theDeltaTime); + mParticle.age(mParticle.age() + pDeltaTime); /* remove dead */ if (HINT_REMOVE_DEAD) { if (mParticle.dead()) { @@ -339,7 +343,7 @@ protected synchronized void advance(float theDeltaTime) { } } - protected synchronized void post(float theDeltaTime) { + protected synchronized void post(float pDeltaTime) { synchronized (mParticles) { for (Particle mParticle : mParticles) { if (mParticle.fixed()) { diff --git a/processing-library/teilchen/src/teilchen/ShortLivedParticle.java b/processing-library/teilchen/src/teilchen/ShortLivedParticle.java index 2a114f3..38aab7a 100755 --- a/processing-library/teilchen/src/teilchen/ShortLivedParticle.java +++ b/processing-library/teilchen/src/teilchen/ShortLivedParticle.java @@ -19,30 +19,30 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; -public class ShortLivedParticle - extends BasicParticle { +public class ShortLivedParticle extends BasicParticle { - private float _myMaxAge; + private float mMaxAge; - public ShortLivedParticle(float theMaxAge) { - _myMaxAge = theMaxAge; + public ShortLivedParticle(float pMaxAge) { + mMaxAge = pMaxAge; } public ShortLivedParticle() { this(1); } - public void setMaxAge(float theMaxAge) { - _myMaxAge = theMaxAge; + public void setMaxAge(float pMaxAge) { + mMaxAge = pMaxAge; } public float ageRatio() { - return Math.min(age() / _myMaxAge, 1); + return Math.min(age() / mMaxAge, 1); } public boolean dead() { - return age() >= _myMaxAge; + return age() >= mMaxAge; } } diff --git a/processing-library/teilchen/src/teilchen/VectorfieldParticle.java b/processing-library/teilchen/src/teilchen/VectorfieldParticle.java index de7786c..aae1289 100755 --- a/processing-library/teilchen/src/teilchen/VectorfieldParticle.java +++ b/processing-library/teilchen/src/teilchen/VectorfieldParticle.java @@ -19,26 +19,26 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; import teilchen.util.Vector3i; -public class VectorfieldParticle - extends BasicParticle { +public class VectorfieldParticle extends BasicParticle { - private Vector3i _myLastUnit; + private Vector3i mLastUnit; public VectorfieldParticle() { super(); - _myLastUnit = new Vector3i(); + mLastUnit = new Vector3i(); } - public void setLastUnit(Vector3i theUnit) { - _myLastUnit = theUnit; + public Vector3i getLastUnit() { + return mLastUnit; } - public Vector3i getLastUnit() { - return _myLastUnit; + public void setLastUnit(Vector3i pUnit) { + mLastUnit = pUnit; } public void accumulateInnerForce(final float pDeltaTime) { diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson00_Particle.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson00_Particle.java index 5ee3e75..00c5c87 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson00_Particle.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson00_Particle.java @@ -7,7 +7,7 @@ public class SketchLesson00_Particle extends PApplet { /* - * this sketch show how to create a particle system with a single particle in it. + * this sketch demonstrates how to create a particle system with a single particle in it. */ private Physics mPhysics; diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson01_Gravity.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson01_Gravity.java index 603cd25..6ccd03a 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson01_Gravity.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson01_Gravity.java @@ -8,7 +8,8 @@ public class SketchLesson01_Gravity extends PApplet { /* - * this sketch show how to create a particle system with a single particle in it. + * this sketch demonstrates how to create a particle system with a single particle in it and a + * gravity force pulling it downward. */ private Physics mPhysics; diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson02_Particles.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson02_Particles.java index 9cc0974..9cd2b2c 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson02_Particles.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson02_Particles.java @@ -8,8 +8,8 @@ public class SketchLesson02_Particles extends PApplet { /* - * this sketch shows how to create and handle multiple particles and remove - * individual particles. + * this sketch demonstrates how to create and handle multiple particles and remove individual + * particles. */ private Physics mPhysics; @@ -47,7 +47,7 @@ public void draw() { for (int i = 0; i < mPhysics.particles().size(); i++) { Particle mParticle = mPhysics.particles(i); if (mParticle.position().y > height * 0.9f) { - mPhysics.particles().remove(i); + mPhysics.particles().remove(i); // @TODO(check if this potentially creates an exception) } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson03_Attractors.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson03_Attractors.java index 1d02d6d..931ffde 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson03_Attractors.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson03_Attractors.java @@ -10,7 +10,7 @@ public class SketchLesson03_Attractors extends PApplet { /* - * this sketch shows how to create and use attractors. + * this sketch demonstrates how to create and use an `Attractor` and how to teleport particles. */ private Physics mPhysics; diff --git a/src/teilchen/examples/SketchLesson05_Spring.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson04_Spring.java similarity index 81% rename from src/teilchen/examples/SketchLesson05_Spring.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson04_Spring.java index 9449630..b096c68 100755 --- a/src/teilchen/examples/SketchLesson05_Spring.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson04_Spring.java @@ -6,11 +6,11 @@ import teilchen.force.Spring; import teilchen.force.ViscousDrag; -public class SketchLesson05_Spring extends PApplet { +public class SketchLesson04_Spring extends PApplet { /* - * this sketch shows 1 how to create a viscous drag to slow motion eventually - * down. 2 how to create a spring that connects two particles. + * this sketch demonstrates how to create a `Spring` that connects two particles. it also + * demonstrates how to create a `ViscousDrag` to slow down particle motion over time. */ private Physics mPhysics; @@ -30,10 +30,10 @@ public void setup() { /* create two particles that we can connect with a spring */ Particle myA = mPhysics.makeParticle(); - myA.position().set(width / 2 - 50, height / 2); + myA.position().set(width / 2 - 50, height / 2.0f); Particle myB = mPhysics.makeParticle(); - myB.position().set(width / 2 + 50, height / 2); + myB.position().set(width / 2 + 50, height / 2.0f); /* create a spring force that connects two particles. * note that there is more than one way to create a spring. @@ -66,6 +66,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson05_Spring.class.getName()}); + PApplet.main(new String[]{SketchLesson04_Spring.class.getName()}); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson06_Springs.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson05_Springs.java similarity index 86% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson06_Springs.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson05_Springs.java index 8128faf..4d0c0da 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson06_Springs.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson05_Springs.java @@ -5,11 +5,10 @@ import teilchen.Physics; import teilchen.force.Spring; -public class SketchLesson06_Springs extends PApplet { +public class SketchLesson05_Springs extends PApplet { /* - * this sketch shows 1 how to create a viscous drag to slow motion eventually - * down. 2 how to create a spring that connects two particles. + * this sketch demonstrates how to connect multiple particles with springs. */ private Physics mPhysics; @@ -24,7 +23,7 @@ public void setup() { mPhysics = new Physics(); /* create a particle to which we will connect springs */ - mRoot = mPhysics.makeParticle(width / 2, height / 2, 0.0f); + mRoot = mPhysics.makeParticle(width / 2.0f, height / 2.0f, 0.0f); /* we give the root particle a higher mass so it doesn t move as easily */ mRoot.mass(30); } @@ -69,7 +68,7 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson06_Springs.class.getName()}); + PApplet.main(new String[]{SketchLesson05_Springs.class.getName()}); } } diff --git a/src/teilchen/examples/SketchLesson07_StableQuads.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson06_StableQuads.java similarity index 89% rename from src/teilchen/examples/SketchLesson07_StableQuads.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson06_StableQuads.java index d75f582..7cedc20 100755 --- a/src/teilchen/examples/SketchLesson07_StableQuads.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson06_StableQuads.java @@ -10,7 +10,12 @@ import teilchen.util.DrawLib; import teilchen.util.StableSpringQuad; -public class SketchLesson07_StableQuads extends PApplet { +public class SketchLesson06_StableQuads extends PApplet { + + /* + * this sketch demonstrates how to connect four particles and six springs to form a + * `StableSpringQuad` a construct that allows to emulate something similar to a *body*. + */ private Physics mPhysics; private Particle mRoot; @@ -83,6 +88,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson07_StableQuads.class.getName()}); + PApplet.main(new String[]{SketchLesson06_StableQuads.class.getName()}); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson08_Sticks.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson07_Sticks.java similarity index 87% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson08_Sticks.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson07_Sticks.java index 5f34b73..70482b7 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson08_Sticks.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson07_Sticks.java @@ -7,7 +7,13 @@ import teilchen.force.Gravity; import teilchen.integration.Verlet; -public class SketchLesson08_Sticks extends PApplet { +public class SketchLesson07_Sticks extends PApplet { + + /* + * this sketch demonstrates how to use a stick to connect two particles. `Stick` is similar to + * `Spring` except that it does not use forces to move particles which results in a more + * *stiff* behavior. + */ private Physics mPhysics; private Particle[] mParticles; @@ -73,6 +79,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson08_Sticks.class.getName()}); + PApplet.main(new String[]{SketchLesson07_Sticks.class.getName()}); } } diff --git a/src/teilchen/examples/SketchLesson09_Cloth.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson08_Cloth.java similarity index 92% rename from src/teilchen/examples/SketchLesson09_Cloth.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson08_Cloth.java index 6fc662c..e064a96 100755 --- a/src/teilchen/examples/SketchLesson09_Cloth.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson08_Cloth.java @@ -10,12 +10,15 @@ import teilchen.force.Gravity; import teilchen.integration.Verlet; -public class SketchLesson09_Cloth extends PApplet { +public class SketchLesson08_Cloth extends PApplet { + + /* + * this sketch demonstrate how to use particles and springs to emulate a piece of cloth. + */ private static final int GRID_WIDTH = 32; private static final int GRID_HEIGHT = 16; private Physics mPhysics; - private Particle[][] mParticles; private Attractor mAttractor; public void settings() { @@ -38,7 +41,7 @@ public void setup() { mAttractor.radius(300); mPhysics.add(mAttractor); - mParticles = new Particle[GRID_WIDTH][GRID_HEIGHT]; + Particle[][] mParticles = new Particle[GRID_WIDTH][GRID_HEIGHT]; /* setup cloth */ float mGridStepX = ((float) width / GRID_WIDTH); @@ -110,6 +113,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson09_Cloth.class.getName()}); + PApplet.main(new String[]{SketchLesson08_Cloth.class.getName()}); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson04_LineDeflector.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson09_LineDeflector.java similarity index 86% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson04_LineDeflector.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson09_LineDeflector.java index a0188f6..fbe1b6b 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson04_LineDeflector.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson09_LineDeflector.java @@ -8,10 +8,11 @@ import teilchen.force.LineDeflector2D; import teilchen.force.ViscousDrag; -public class SketchLesson04_LineDeflector extends PApplet { +public class SketchLesson09_LineDeflector extends PApplet { /* - * this sketch shows 1 how to create and use line deflectors 2 how to use 'ShortLivedParticle' + * this sketch demonstrates how to create and use `LineDeflector2D` and how to use + * `ShortLivedParticle` a particle that only exists for a defined period of time. */ private Physics mPhysics; @@ -26,8 +27,8 @@ public void setup() { mPhysics = new Physics(); mDeflector = new LineDeflector2D(); - mDeflector.a().set(50, height / 2); - mDeflector.b().set(width - 50, height / 2 - 100); + mDeflector.a().set(50, height / 2.0f); + mDeflector.b().set(width - 50, height / 2.0f - 100); mPhysics.add(mDeflector); /* create gravity */ @@ -87,6 +88,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(SketchLesson04_LineDeflector.class.getName()); + PApplet.main(SketchLesson09_LineDeflector.class.getName()); } } diff --git a/src/teilchen/examples/SketchLesson04_PlaneDeflector.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson10_PlaneDeflector.java similarity index 91% rename from src/teilchen/examples/SketchLesson04_PlaneDeflector.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson10_PlaneDeflector.java index 5ebb4da..ce9e26b 100755 --- a/src/teilchen/examples/SketchLesson04_PlaneDeflector.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson10_PlaneDeflector.java @@ -8,11 +8,11 @@ import teilchen.force.PlaneDeflector; import teilchen.force.ViscousDrag; -public class SketchLesson04_PlaneDeflector extends PApplet { +public class SketchLesson10_PlaneDeflector extends PApplet { /* - * this sketch shows 1 how to create and use plane deflectors 2 how to use - * 'ShortLivedParticle' + * this sketch demonstrates how to create and use ``PlaneDeflector` and how to use + * `ShortLivedParticle` a particle that only exists for a defined period of time. */ private Physics mPhysics; @@ -35,7 +35,7 @@ public void setup() { */ mDeflector = new PlaneDeflector(); /* set plane origin into the center of the screen */ - mDeflector.plane().origin.set(width / 2, height / 2, 0); + mDeflector.plane().origin.set(width / 2.0f, height / 2.0f, 0); mDeflector.plane().normal.set(0, -1, 0); /* the coefficient of restitution defines how hard particles bounce of the deflector */ mDeflector.coefficientofrestitution(0.7f); @@ -108,6 +108,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson04_PlaneDeflector.class.getName()}); + PApplet.main(new String[]{SketchLesson10_PlaneDeflector.class.getName()}); } } diff --git a/src/teilchen/examples/SketchLesson10_WanderBehavior.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson11_WanderBehavior.java similarity index 83% rename from src/teilchen/examples/SketchLesson10_WanderBehavior.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson11_WanderBehavior.java index 2f6a481..cd40d0f 100755 --- a/src/teilchen/examples/SketchLesson10_WanderBehavior.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson11_WanderBehavior.java @@ -7,10 +7,11 @@ import teilchen.behavior.Wander; import teilchen.force.ViscousDrag; -public class SketchLesson10_WanderBehavior extends PApplet { +public class SketchLesson11_WanderBehavior extends PApplet { /* - * this sketch shows how to assign an 'wander' behavior to a particle. + * this sketch demonstrates how to use behaviors. it combines `Wander` and `Motor` behaviors + * to turn a `BehaviorParticle` into an autonomously moving *agent*. */ private Physics mPhysics; @@ -31,7 +32,7 @@ public void setup() { /* create particles */ mParticle = mPhysics.makeParticle(BehaviorParticle.class); - mParticle.position().set(width / 2, height / 2); + mParticle.position().set(width / 2.0f, height / 2.0f); mParticle.maximumInnerForce(100); mParticle.radius(10); @@ -67,6 +68,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson10_WanderBehavior.class.getName()}); + PApplet.main(new String[]{SketchLesson11_WanderBehavior.class.getName()}); } } diff --git a/src/teilchen/examples/SketchLesson11_ArrivalBehavior.java b/processing-library/teilchen/src/teilchen/examples/SketchLesson12_ArrivalBehavior.java similarity index 88% rename from src/teilchen/examples/SketchLesson11_ArrivalBehavior.java rename to processing-library/teilchen/src/teilchen/examples/SketchLesson12_ArrivalBehavior.java index 4e11fc0..eff4e46 100755 --- a/src/teilchen/examples/SketchLesson11_ArrivalBehavior.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLesson12_ArrivalBehavior.java @@ -5,10 +5,11 @@ import teilchen.Physics; import teilchen.behavior.Arrival; -public class SketchLesson11_ArrivalBehavior extends PApplet { +public class SketchLesson12_ArrivalBehavior extends PApplet { /* - * this sketch shows how to assign an 'arrival' behavior to a particle. + * this sketch demonstrates how to use behaviors. it appliies the `Arrival` behavior to make a + * `BehaviorParticle` arrive at a certain location. */ private Physics mPhysics; @@ -75,6 +76,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson11_ArrivalBehavior.class.getName()}); + PApplet.main(new String[]{SketchLesson12_ArrivalBehavior.class.getName()}); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX01_Overlap.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX01_Overlap.java index c453812..e46c3da 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX01_Overlap.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX01_Overlap.java @@ -12,8 +12,8 @@ public class SketchLessonX01_Overlap extends PApplet { /* - * this sketch is exactly like Lesson06_Springs, except that it also shows how - * to resolveOverlap overlaps. + * this sketch is exactly like `Lesson06_Springs` except that it also shows how to resolve + * overlaps of particles by moving particles apart manipulating their position directly. */ private static final float PARTICLE_RADIUS = 13; @@ -31,7 +31,7 @@ public void setup() { mPhysics.add(new ViscousDrag()); mPhysics.add(new Gravity(new PVector(0, 100f, 0))); - mRoot = mPhysics.makeParticle(width / 2, height / 2, 0.0f); + mRoot = mPhysics.makeParticle(width / 2.0f, height / 2.0f, 0.0f); mRoot.mass(30); mRoot.fixed(true); mRoot.radius(PARTICLE_RADIUS); @@ -52,7 +52,7 @@ public void draw() { /* move overlapping particles away from each other */ for (int i = 0; i < 10; i++) { - mRoot.position().set(width / 2, height / 2, 0.0f); // a bit of a 'hack' + mRoot.position().set(width / 2.0f, height / 2.0f, 0.0f); // a bit of a 'hack' Overlap.resolveOverlap(mPhysics.particles()); } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX02_Collisions.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX02_Collisions.java index d7fe5e5..31f07fd 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX02_Collisions.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX02_Collisions.java @@ -12,6 +12,11 @@ public class SketchLessonX02_Collisions extends PApplet { + /* + * this sketch demonstrates how to use `CollisionManager` to resolve particle collisions by + * applying temporary springs pushing 2 colliding particles appart. + */ + private static final float PARTICLE_SIZE = 12; private CollisionManager mCollision; private Physics mPhysics; diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX03_ParticlesLeavingTrails.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX03_ParticlesLeavingTrails.java index c88e7cd..5727568 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX03_ParticlesLeavingTrails.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX03_ParticlesLeavingTrails.java @@ -15,6 +15,10 @@ public class SketchLessonX03_ParticlesLeavingTrails extends PApplet { + /* + * this sketch demonstrates how to use `ParticleTrail` to make particles leave a trail. + */ + private Physics mPhysics; private ArrayList mTrails; private Attractor mAttractor; @@ -61,15 +65,7 @@ public void setup() { myParticleTrail.mass(0.5f); mTrails.add(myParticleTrail); } - resetParticles(width / 2, height / 2); - } - - private void resetParticles(float x, float y) { - for (ParticleTrail myTrails : mTrails) { - myTrails.particle().position().set(x + random(-10, 10), y + random(-10, 10), 0); - myTrails.particle().velocity().set(random(-10, 10), random(-10, 10), random(-10, 10)); - myTrails.fragments().clear(); - } + resetParticles(width / 2.0f, height / 2.0f); } public void draw() { @@ -88,6 +84,18 @@ public void draw() { } } + public void mousePressed() { + resetParticles(mouseX, mouseY); + } + + private void resetParticles(float x, float y) { + for (ParticleTrail myTrails : mTrails) { + myTrails.particle().position().set(x + random(-10, 10), y + random(-10, 10), 0); + myTrails.particle().velocity().set(random(-10, 10), random(-10, 10), random(-10, 10)); + myTrails.fragments().clear(); + } + } + private void drawTrail(ParticleTrail theTrail) { final ArrayList mFragments = theTrail.fragments(); @@ -129,10 +137,6 @@ private void drawTrail(ParticleTrail theTrail) { } } - public void mousePressed() { - resetParticles(mouseX, mouseY); - } - public static void main(String[] args) { PApplet.main(new String[]{SketchLessonX03_ParticlesLeavingTrails.class.getName()}); } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX04_StickMan.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX04_StickMan.java index a09d41e..e6bad26 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX04_StickMan.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX04_StickMan.java @@ -13,14 +13,13 @@ public class SketchLessonX04_StickMan extends PApplet { /* - * this demo shows some advanced use of particles, springs and attractors to - * create stickmen. + * this sketch demonstratwa some advanced use of particles, springs ( e.g `MuscleSpring` ) + * and attractors to create a group of `StickMan`. */ private Physics mPhysics; private Attractor mAttractor; private Gravity mGravity; - private ViscousDrag mViscousDrag; private StickMan[] mMyStickMan; public void settings() { @@ -38,14 +37,14 @@ public void setup() { mGravity.force().y = 20; mPhysics.add(mGravity); - mViscousDrag = new ViscousDrag(); + ViscousDrag mViscousDrag = new ViscousDrag(); mViscousDrag.coefficient = 0.85f; mPhysics.add(mViscousDrag); mAttractor = new Attractor(); mAttractor.radius(500); mAttractor.strength(0); - mAttractor.position().set(width / 2, height / 2); + mAttractor.position().set(width / 2.0f, height / 2.0f); mPhysics.add(mAttractor); mMyStickMan = new StickMan[20]; diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX05_AngleConstraints.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX05_AngleConstraints.java index 787e3a5..3bb41c7 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX05_AngleConstraints.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX05_AngleConstraints.java @@ -13,6 +13,10 @@ public class SketchLessonX05_AngleConstraints extends PApplet { + /* + * this sketch demonstrates how to contraint the angle between two springs or two sticks. + */ + private Physics mPhysics; private Particle mParticleA; private Particle mParticleB; @@ -43,10 +47,10 @@ public void setup() { mParticleC = mPhysics.makeParticle(); mParticleD = mPhysics.makeParticle(); - mParticleA.position().set(width / 2 + 50, height / 3); - mParticleB.position().set(width / 2, height - height / 1.75f); - mParticleC.position().set(width / 2, height - height / 4); - mParticleD.position().set(width / 2, height - height / 8); + mParticleA.position().set(width / 2.0f + 50, height / 3.0f); + mParticleB.position().set(width / 2.0f, height - height / 1.75f); + mParticleC.position().set(width / 2.0f, height - height / 4.0f); + mParticleD.position().set(width / 2.0f, height - height / 8.0f); mParticleA.radius(7); mParticleB.radius(3); diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX06_Ducklings.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX06_Ducklings.java index 90651c5..325110c 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX06_Ducklings.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX06_Ducklings.java @@ -13,8 +13,8 @@ public class SketchLessonX06_Ducklings extends PApplet { /* - * this demo shows how to add behaviors to particles. in this example the - * arrival behavior. + * this sketch demonstrates how to use `Arrival` behaviors with particles to create a group of + * ducklings. */ private Physics mPhysics; @@ -26,7 +26,6 @@ public void settings() { } public void setup() { - frameRate(60); colorMode(RGB, 1.0f); /* physics */ diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX07_CubicleWorld.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX07_CubicleWorld.java index 948fb24..94e9ba3 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX07_CubicleWorld.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX07_CubicleWorld.java @@ -12,14 +12,20 @@ public class SketchLessonX07_CubicleWorld extends PApplet { + /* + * this sketch demonstrates how to use `CubicleWorld` to separate a given space into equally + * sized cubes in order to only draw paticles from a specific cube. this mechanism is helpful + * to avoid decrease the in demand for computational resources in particle systems with large + * numbers of particles. + */ + private final int WORLD_NUMBER_OF_CUBICLES = 15; private final float WORLD_CUBICLE_SCALE = 20; private final float WORLD_SCALE = WORLD_NUMBER_OF_CUBICLES * WORLD_CUBICLE_SCALE; - private final boolean showCubicles = true; + private final boolean mShowCubicles = true; private final PVector mPosition = new PVector(); private float mRotationZ = 0.1f; private CubicleWorld mCubicleWorld; - private CubicleWorldView mCubicleWorldView; public void settings() { @@ -38,16 +44,14 @@ public void setup() { mCubicleWorldView = new CubicleWorldView(mCubicleWorld); mCubicleWorldView.color_empty = color(0, 1); - mCubicleWorldView.color_full = color(0, 4); + mCubicleWorldView.color_full = color(0, 2); mCubicleWorld.add(new MCubicleEntity()); } public void draw() { - /* handle entities */ - if (frameRate > 30) { - addRandomEntities(2); - } + /* add entities */ + addRandomEntities(10); mCubicleWorld.update(); ArrayList mEntities = mCubicleWorld.getLocalEntities(mPosition, 1); @@ -56,22 +60,21 @@ public void draw() { background(255); pushMatrix(); - translate(width / 2, height / 2, 0); + translate(width / 2.0f, height / 2.0f, 0); /* rotate */ if (mousePressed) { mRotationZ += (mouseX * 0.01f - mRotationZ) * 0.05f; } else { - mPosition.x = mouseX - width / 2; - mPosition.y = mouseY - height / 2; + mPosition.x = mouseX - width / 2.0f; + mPosition.y = mouseY - height / 2.0f; } rotateX(THIRD_PI); rotateZ(mRotationZ); /* draw cubicle world */ - if (showCubicles) { - strokeWeight(0.1f); - stroke(0, 127); + if (mShowCubicles) { + strokeWeight(1.0f / mCubicleWorld.cellscale().x); // unscale stroke weight noFill(); mCubicleWorldView.draw(g); } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX08_Schwarm.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX08_Schwarm.java index 35a0df1..aa65021 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX08_Schwarm.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX08_Schwarm.java @@ -18,6 +18,11 @@ public class SketchLessonX08_Schwarm extends PApplet { + /* + * this sketch demonstrates how to create a complex swarm behavior by combining the four simple + * behaviors `Separation`, `Alignment`, `Cohesion` and `Wander` ( plus `Motor` ). + */ + private Physics mPhysics; private ArrayList mSwarmEntities; @@ -73,13 +78,9 @@ public void draw() { private class SwarmEntity extends BehaviorParticle { private final Separation separation; - private final Alignment alignment; - private final Cohesion cohesion; - private final Wander wander; - private final Motor motor; public SwarmEntity() { diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX09_TriangleDeflector.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX09_TriangleDeflector.java index 526380d..6b458b1 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX09_TriangleDeflector.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX09_TriangleDeflector.java @@ -2,6 +2,7 @@ import processing.core.PApplet; import processing.core.PVector; +import teilchen.MortalParticle; import teilchen.Particle; import teilchen.Physics; import teilchen.force.Gravity; @@ -12,6 +13,12 @@ public class SketchLessonX09_TriangleDeflector extends PApplet { + /* + * this sketch demonstrates how to use `TriangleDeflectors` to make particles bounce off two + * triangles. it also demonstrates how to use `MortalParticle` to remove particles + * automatically once they leave the screen. + */ + private Physics mPhysics; private ArrayList mTriangleDeflectors; @@ -31,9 +38,7 @@ public void setup() { /* triangle deflectors */ final PVector[] mVertices = new PVector[]{new PVector(0, 0, 0), new PVector(width, height, 0), - new PVector(0, - height, - 0), + new PVector(0, height, 0), new PVector(0, 0, 0), new PVector(width, 0, 0), new PVector(width, height, 0),}; @@ -44,26 +49,19 @@ public void setup() { public void draw() { if (mousePressed) { /* create and add a particle to the system */ - Particle mParticle = mPhysics.makeParticle(); + MyMortalParticle mParticle = new MyMortalParticle(); + mPhysics.add(mParticle); /* set particle to mouse position with random velocity */ - mParticle.position().set(mouseX, random(height), height / 2); + mParticle.position().set(mouseX, random(height), height / 2.0f); mParticle.velocity().set(random(-20, 20), 0, random(20)); } final float mDeltaTime = 1.0f / frameRate; mPhysics.step(mDeltaTime); - /* remove particles */ - for (int i = 0; i < mPhysics.particles().size(); i++) { - Particle mParticle = mPhysics.particles(i); - if (mParticle.position().z < -height) { - mPhysics.particles().remove(i); - } - } - /* draw particles */ background(255); - camera(width / 2, mouseY + height, height * 1.3f - mouseY, width / 2, height / 2, 0, 0, 1, 0); + camera(width / 2.0f, mouseY + height, height * 1.3f - mouseY, width / 2.0f, height / 2.0f, 0, 0, 1, 0); noStroke(); sphereDetail(10); @@ -90,6 +88,13 @@ public void draw() { mPhysics.removeTags(); } + private class MyMortalParticle extends MortalParticle { + + public boolean isDead() { + return position().z < -height; + } + } + public static void main(String[] args) { PApplet.main(new String[]{SketchLessonX09_TriangleDeflector.class.getName()}); } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX10_TriangleDeflector2D.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX10_TriangleDeflector2D.java index bc00b9a..0a26a8c 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX10_TriangleDeflector2D.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX10_TriangleDeflector2D.java @@ -1,6 +1,7 @@ package teilchen.examples; import processing.core.PApplet; +import teilchen.MortalParticle; import teilchen.Particle; import teilchen.Physics; import teilchen.force.Gravity; @@ -8,6 +9,12 @@ public class SketchLessonX10_TriangleDeflector2D extends PApplet { + /* + * this sketch demonstrates how to use `TriangleDeflectors` in a 2D context to make particles + * bounce off a triangle ( that looks like a line ). it also demonstrates how to use + * `MortalParticle` to remove particles automatically once they leave the screen. + */ + private Physics mPhysics; private TriangleDeflector mTriangleDeflector; @@ -35,14 +42,6 @@ public void draw() { final float mDeltaTime = 1.0f / frameRate; mPhysics.step(mDeltaTime); - /* remove particles */ - for (int i = 0; i < mPhysics.particles().size(); i++) { - Particle mParticle = mPhysics.particles(i); - if (mParticle.position().y > height || mParticle.still()) { - mPhysics.particles().remove(i); //@TODO(this might cause an exception. should be replaced by iterator) - } - } - /* draw particles */ background(255); @@ -67,14 +66,22 @@ public void draw() { /* finally remove the collision tag */ mPhysics.removeTags(); + + if (mousePressed) { + /* create and add a particle to the system */ + MyMortalParticle mParticle = new MyMortalParticle(); + mPhysics.add(mParticle); + /* set particle to mouse position with random velocity */ + mParticle.position().set(mouseX, mouseY); + mParticle.velocity().set(random(-20, 20), 0); + } } - public void mousePressed() { - /* create and add a particle to the system */ - Particle mParticle = mPhysics.makeParticle(); - /* set particle to mouse position with random velocity */ - mParticle.position().set(mouseX, mouseY); - mParticle.velocity().set(random(-20, 20), 0); + private class MyMortalParticle extends MortalParticle { + + public boolean isDead() { + return position().y > height || still(); + } } public static void main(String[] args) { diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX12_Pendulum.java b/processing-library/teilchen/src/teilchen/examples/SketchLessonX11_Pendulum.java similarity index 83% rename from processing-library/teilchen/src/teilchen/examples/SketchLessonX12_Pendulum.java rename to processing-library/teilchen/src/teilchen/examples/SketchLessonX11_Pendulum.java index 02d480d..aaffed5 100644 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX12_Pendulum.java +++ b/processing-library/teilchen/src/teilchen/examples/SketchLessonX11_Pendulum.java @@ -6,12 +6,15 @@ import teilchen.force.Gravity; import teilchen.force.Pulse; import teilchen.force.Spring; -import teilchen.integration.Verlet; -public class SketchLessonX12_Pendulum extends PApplet { +public class SketchLessonX11_Pendulum extends PApplet { - private Physics mPhysics; + /* + * this sketch demonstrates how to create a pendulum from two particles, a spring and a pulse + * force. + */ + private Physics mPhysics; private Particle mPendulumRoot; private Particle mPendulumTip; private Pulse mPulse; @@ -27,12 +30,12 @@ public void setup() { mPhysics.add(mGravity); mPendulumRoot = mPhysics.makeParticle(0, 0, 0, 0.05f); - mPendulumRoot.position().set(width / 2, 100); + mPendulumRoot.position().set(width / 2.0f, 100); mPendulumRoot.fixed(true); mPendulumTip = mPhysics.makeParticle(0, 0, 0, 0.05f); - float mSegmentLength = height / 2; + float mSegmentLength = height / 2.0f; Spring mConnection = new Spring(mPendulumRoot, mPendulumTip, mSegmentLength); mConnection.damping(0.0f); mConnection.strength(10); @@ -68,6 +71,6 @@ public void mousePressed() { } public static void main(String[] args) { - PApplet.main(SketchLessonX12_Pendulum.class.getName()); + PApplet.main(SketchLessonX11_Pendulum.class.getName()); } } diff --git a/processing-library/teilchen/src/teilchen/force/MuscleSpring.java b/processing-library/teilchen/src/teilchen/force/MuscleSpring.java index 3867af2..f7e71b8 100755 --- a/processing-library/teilchen/src/teilchen/force/MuscleSpring.java +++ b/processing-library/teilchen/src/teilchen/force/MuscleSpring.java @@ -66,8 +66,8 @@ public float restlength() { return mInitialRestLength; } - public void restlength(float theRestLength) { - mInitialRestLength = theRestLength; + public void restlength(float pRestLength) { + mInitialRestLength = pRestLength; } public void frequency(final float theFrequency) { diff --git a/processing-library/teilchen/src/teilchen/force/Spring.java b/processing-library/teilchen/src/teilchen/force/Spring.java index 533d9d9..7a33f39 100755 --- a/processing-library/teilchen/src/teilchen/force/Spring.java +++ b/processing-library/teilchen/src/teilchen/force/Spring.java @@ -31,43 +31,37 @@ public class Spring implements IForce, IConnection { protected float mSpringConstant; - protected float mSpringDamping; - protected float mRestLength; - protected Particle mA; - protected Particle mB; - protected boolean mOneWay; - protected boolean mActive; - public Spring(Particle theA, Particle theB) { - this(theA, theB, 2.0f, 0.1f, distance(theA.position(), theB.position())); + public Spring(Particle pA, Particle pB) { + this(pA, pB, 2.0f, 0.1f, distance(pA.position(), pB.position())); } - public Spring(final Particle theA, - final Particle theB, - final float theSpringConstant, - final float theSpringDamping, - final float theRestLength) { - mSpringConstant = theSpringConstant; - mSpringDamping = theSpringDamping; - mRestLength = theRestLength; - mA = theA; - mB = theB; + public Spring(final Particle pA, + final Particle pB, + final float pSpringConstant, + final float pSpringDamping, + final float pRestLength) { + mSpringConstant = pSpringConstant; + mSpringDamping = pSpringDamping; + mRestLength = pRestLength; + mA = pA; + mB = pB; mOneWay = false; mActive = true; } - public Spring(Particle theA, Particle theB, float theRestLength) { - this(theA, theB, 2.0f, 0.1f, theRestLength); + public Spring(Particle pA, Particle pB, float pRestLength) { + this(pA, pB, 2.0f, 0.1f, pRestLength); } - public Spring(Particle theA, Particle theB, final float theSpringConstant, final float theSpringDamping) { - this(theA, theB, theSpringConstant, theSpringDamping, distance(theA.position(), theB.position())); + public Spring(Particle pA, Particle pB, final float pSpringConstant, final float pSpringDamping) { + this(pA, pB, pSpringConstant, pSpringDamping, distance(pA.position(), pB.position())); } public void setRestLengthByPosition() { @@ -78,8 +72,8 @@ public float restlength() { return mRestLength; } - public void restlength(float theRestLength) { - mRestLength = theRestLength; + public void restlength(float pRestLength) { + mRestLength = pRestLength; } public final Particle a() { @@ -90,46 +84,36 @@ public final Particle b() { return mB; } - public final Particle a(Particle theA) { - return mA = theA; + public final Particle a(Particle pA) { + return mA = pA; } - public final Particle b(Particle theB) { - return mB = theB; + public final Particle b(Particle pB) { + return mB = pB; } public final float currentLength() { return distance(mA.position(), mB.position()); } - /** - spring constant. - - @return float - */ public final float strength() { return mSpringConstant; } - /** - spring constant. - - @param theSpringConstant float - */ - public final void strength(float theSpringConstant) { - mSpringConstant = theSpringConstant; + public final void strength(float pSpringConstant) { + mSpringConstant = pSpringConstant; } public final float damping() { return mSpringDamping; } - public final void damping(float theSpringDamping) { - mSpringDamping = theSpringDamping; + public final void damping(float pSpringDamping) { + mSpringDamping = pSpringDamping; } - public void setOneWay(boolean theOneWayState) { - mOneWay = theOneWayState; + public void setOneWay(boolean pOneWayState) { + mOneWay = pOneWayState; } public void apply(final float pDeltaTime, final Physics pParticleSystem) { @@ -175,14 +159,6 @@ public void apply(final float pDeltaTime, final Physics pParticleSystem) { // } } - protected static float fastInverseSqrt(float v) { - final float half = 0.5f * v; - int i = Float.floatToIntBits(v); - i = 0x5f375a86 - (i >> 1); - v = Float.intBitsToFloat(i); - return v * (1.5f - half * v * v); - } - public boolean dead() { return mA.dead() || mB.dead(); } @@ -194,4 +170,12 @@ public boolean active() { public void active(boolean pActiveState) { mActive = pActiveState; } + + protected static float fastInverseSqrt(float v) { + final float half = 0.5f * v; + int i = Float.floatToIntBits(v); + i = 0x5f375a86 - (i >> 1); + v = Float.intBitsToFloat(i); + return v * (1.5f - half * v * v); + } } diff --git a/processing-library/teilchen/src/teilchen/test/TestIntersectRayTriangle.java b/processing-library/teilchen/src/teilchen/test/TestIntersectRayTriangle.java index 81147f7..b14ade4 100755 --- a/processing-library/teilchen/src/teilchen/test/TestIntersectRayTriangle.java +++ b/processing-library/teilchen/src/teilchen/test/TestIntersectRayTriangle.java @@ -22,7 +22,7 @@ public void setup() { public void draw() { background(50); - translate(width / 2, height / 2); + translate(width / 2.0f, height / 2.0f); if (!mousePressed) { mRotationX = TWO_PI * mouseY / (float) height; mRotationY = TWO_PI * mouseX / (float) width; @@ -33,8 +33,8 @@ public void draw() { PVector rayOrigin = new PVector(0, 0, 0); PVector rayVector = new PVector(mRayX, mRayY, -100); if (mousePressed) { - mRayX = mouseX - width / 2; - mRayY = mouseY - height / 2; + mRayX = mouseX - width / 2.0f; + mRayY = mouseY - height / 2.0f; } PVector v0 = new PVector(-100, -100, -200); PVector v1 = new PVector(100, -100, -200); diff --git a/processing-library/teilchen/src/teilchen/util/CollisionManager.java b/processing-library/teilchen/src/teilchen/util/CollisionManager.java index 2e91ff3..057b956 100755 --- a/processing-library/teilchen/src/teilchen/util/CollisionManager.java +++ b/processing-library/teilchen/src/teilchen/util/CollisionManager.java @@ -19,19 +19,22 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen.util; -import java.util.ArrayList; import processing.core.PVector; import teilchen.Particle; import teilchen.Physics; -import static teilchen.Physics.EPSILON; import teilchen.constraint.Stick; import teilchen.cubicle.CubicleParticle; import teilchen.cubicle.CubicleWorld; import teilchen.cubicle.ICubicleEntity; import teilchen.force.IForce; import teilchen.force.Spring; + +import java.util.ArrayList; + +import static teilchen.Physics.EPSILON; import static teilchen.util.Util.distance; import static teilchen.util.Util.lengthSquared; @@ -42,38 +45,19 @@ */ public class CollisionManager { + public static final int DISTANCE_MODE_RADIUS = 0; + public static final int DISTANCE_MODE_FIXED = 1; public boolean HINT_IGNORE_STILL_OR_FIXED = false; - + private final Physics mCollisionPhysics; + private final Random mRandom; private float mCollisionSpringConstant; - private float mCollisionSpringDamping; - - private final Physics mCollisionPhysics; - private float mMinimumDistance; - - private PVector mResolveSamePosition; - - public enum ResolverType { -// COLLISION_STICK, COLLISION_SPRING, - - SPRING, STICK - - } - private final Random mRandom; - + private final PVector mResolveSamePosition; private ResolverType mResolverType; - private float mCollisionResolverIntervalCounter = 1; - private float mCollisionResolverInterval = 0; - private int mDistanceMode = DISTANCE_MODE_FIXED; - - public static final int DISTANCE_MODE_RADIUS = 0; - - public static final int DISTANCE_MODE_FIXED = 1; - public CollisionManager() { this(new Physics()); } @@ -178,6 +162,15 @@ public void createCollisionResolvers() { } } + public void createCollisionResolvers(final CubicleWorld theWorld) { + for (int i = 0; i < mCollisionPhysics.particles().size(); i++) { + final Particle myParticle = mCollisionPhysics.particles().get(i); + if (myParticle instanceof CubicleParticle) { + createCollisionResolver(theWorld, (CubicleParticle) myParticle); + } + } + } + private void createCollisionResolver(final Particle theParticle, final int theStart) { if (HINT_IGNORE_STILL_OR_FIXED) { if (theParticle.fixed() || theParticle.still()) { @@ -193,7 +186,7 @@ private void createCollisionResolver(final Particle theParticle, final int theSt if (theParticle.fixed() && myOtherParticle.fixed()) { // continue; } - /** + /* * because of the way we handle the collision resolver * creation there is no need to check for multiple spring * connections. @@ -228,15 +221,6 @@ private void createCollisionResolver(final Particle theParticle, final int theSt } } - public void createCollisionResolvers(final CubicleWorld theWorld) { - for (int i = 0; i < mCollisionPhysics.particles().size(); i++) { - final Particle myParticle = mCollisionPhysics.particles().get(i); - if (myParticle instanceof CubicleParticle) { - createCollisionResolver(theWorld, (CubicleParticle) myParticle); - } - } - } - private void createCollisionResolver(final CubicleWorld theWorld, final CubicleParticle theParticle) { if (HINT_IGNORE_STILL_OR_FIXED) { if (theParticle.fixed() || theParticle.still()) { @@ -305,6 +289,11 @@ private float getMinimumDistance(Particle theParticle, Particle myOtherParticle) return myMinimumDistance; } + public enum ResolverType { + // COLLISION_STICK, COLLISION_SPRING, + SPRING, STICK + } + public static class CollisionSpring extends Spring { diff --git a/processing-library/teilchen/src/teilchen/util/StickMan.java b/processing-library/teilchen/src/teilchen/util/StickMan.java index 8af6fae..e736d88 100755 --- a/processing-library/teilchen/src/teilchen/util/StickMan.java +++ b/processing-library/teilchen/src/teilchen/util/StickMan.java @@ -11,15 +11,10 @@ public class StickMan { private final StableSpringQuad _myQuad; - private final float _myScale; - private final BasicParticle myLeftFoot; - private final BasicParticle myRightFoot; - private final BasicParticle myLeftHand; - private final BasicParticle myRightHand; public StickMan(Physics theParticleSystem, float theOffset, float theScale) { diff --git a/processing-library/teilchen/src/teilchen/wip/Sketch_ExplodingZeldaShrine.java b/processing-library/teilchen/src/teilchen/wip/Sketch_ExplodingZeldaShrine.java index 6e7d20a..9062ed6 100755 --- a/processing-library/teilchen/src/teilchen/wip/Sketch_ExplodingZeldaShrine.java +++ b/processing-library/teilchen/src/teilchen/wip/Sketch_ExplodingZeldaShrine.java @@ -16,7 +16,7 @@ public void settings() { } public void setup() { - p1.set(width / 2, height / 2); + p1.set(width / 2.0f, height / 2.0f); } public void draw() { @@ -40,7 +40,7 @@ private void laser_line(PVector v1, PVector d = PVector.sub(v2, v1); PVector c = new PVector(-d.y, d.x); c.normalize(); - c.mult(pLineWidth / 2); + c.mult(pLineWidth / 2.0f); beginShape(QUADS); /* core */ fill(pColorCore); diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLessonX11_NonIntersectingStructures.java b/processing-library/teilchen/src/teilchen/wip/Sketch_NonIntersectingStructures.java similarity index 93% rename from processing-library/teilchen/src/teilchen/examples/SketchLessonX11_NonIntersectingStructures.java rename to processing-library/teilchen/src/teilchen/wip/Sketch_NonIntersectingStructures.java index ee463fe..4ea56f1 100644 --- a/processing-library/teilchen/src/teilchen/examples/SketchLessonX11_NonIntersectingStructures.java +++ b/processing-library/teilchen/src/teilchen/wip/Sketch_NonIntersectingStructures.java @@ -1,4 +1,4 @@ -package teilchen.examples; +package teilchen.wip; import processing.core.PApplet; import teilchen.Particle; @@ -10,7 +10,7 @@ import java.util.ArrayList; -public class SketchLessonX11_NonIntersectingStructures extends PApplet { +public class Sketch_NonIntersectingStructures extends PApplet { // @TODO(not fully functional yet) @@ -86,6 +86,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(SketchLessonX11_NonIntersectingStructures.class.getName()); + PApplet.main(Sketch_NonIntersectingStructures.class.getName()); } } diff --git a/reference/allclasses-frame.html b/reference/allclasses-frame.html index 7859b49..985088f 100644 --- a/reference/allclasses-frame.html +++ b/reference/allclasses-frame.html @@ -2,9 +2,9 @@ - + All Classes - + @@ -26,7 +26,6 @@

    All Classes

  • CollisionManager.CollisionSpring
  • CollisionManager.CollisionStick
  • CollisionManager.ResolverType
  • -
  • ConditionalParticle
  • CubicleAtom
  • CubicleEntity
  • CubicleParticle
  • @@ -37,9 +36,9 @@

    All Classes

  • DrawLib
  • Euler
  • Flee
  • -
  • FlowField
  • -
  • FlowFieldForce
  • -
  • FlowFieldForceMOUSE
  • +
  • FlowField
  • +
  • FlowFieldForce
  • +
  • FlowFieldForceMOUSE
  • Gravity
  • IBehavior
  • IBehaviorParticle
  • @@ -56,6 +55,7 @@

    All Classes

  • LineIntersectionConstraint
  • Matrix3f
  • Midpoint
  • +
  • MortalParticle
  • Motor
  • MuscleSpring
  • Overlap
  • @@ -92,12 +92,12 @@

    All Classes

  • Util.ProximityStructure
  • Vector3i
  • Vector4f
  • -
  • VectorField
  • -
  • VectorFieldGenerator
  • -
  • VectorFieldGeneratorAVERAGEUNITS
  • -
  • VectorFieldGeneratorRANDOM
  • +
  • VectorField
  • +
  • VectorFieldGenerator
  • +
  • VectorFieldGeneratorAVERAGEUNITS
  • +
  • VectorFieldGeneratorRANDOM
  • VectorfieldParticle
  • -
  • VectorFieldUnit
  • +
  • VectorFieldUnit
  • Verhalten
  • Verlet
  • ViscousDrag
  • diff --git a/reference/allclasses-noframe.html b/reference/allclasses-noframe.html index 9b2c2f2..4b1b6c5 100644 --- a/reference/allclasses-noframe.html +++ b/reference/allclasses-noframe.html @@ -2,9 +2,9 @@ - + All Classes - + @@ -26,7 +26,6 @@

    All Classes

  • CollisionManager.CollisionSpring
  • CollisionManager.CollisionStick
  • CollisionManager.ResolverType
  • -
  • ConditionalParticle
  • CubicleAtom
  • CubicleEntity
  • CubicleParticle
  • @@ -37,9 +36,9 @@

    All Classes

  • DrawLib
  • Euler
  • Flee
  • -
  • FlowField
  • -
  • FlowFieldForce
  • -
  • FlowFieldForceMOUSE
  • +
  • FlowField
  • +
  • FlowFieldForce
  • +
  • FlowFieldForceMOUSE
  • Gravity
  • IBehavior
  • IBehaviorParticle
  • @@ -56,6 +55,7 @@

    All Classes

  • LineIntersectionConstraint
  • Matrix3f
  • Midpoint
  • +
  • MortalParticle
  • Motor
  • MuscleSpring
  • Overlap
  • @@ -92,12 +92,12 @@

    All Classes

  • Util.ProximityStructure
  • Vector3i
  • Vector4f
  • -
  • VectorField
  • -
  • VectorFieldGenerator
  • -
  • VectorFieldGeneratorAVERAGEUNITS
  • -
  • VectorFieldGeneratorRANDOM
  • +
  • VectorField
  • +
  • VectorFieldGenerator
  • +
  • VectorFieldGeneratorAVERAGEUNITS
  • +
  • VectorFieldGeneratorRANDOM
  • VectorfieldParticle
  • -
  • VectorFieldUnit
  • +
  • VectorFieldUnit
  • Verhalten
  • Verlet
  • ViscousDrag
  • diff --git a/reference/constant-values.html b/reference/constant-values.html index ec9ef8a..2a4c3c9 100644 --- a/reference/constant-values.html +++ b/reference/constant-values.html @@ -2,9 +2,9 @@ - + Constant Field Values - + diff --git a/reference/help-doc.html b/reference/help-doc.html index 9f79aa6..5abb0d6 100644 --- a/reference/help-doc.html +++ b/reference/help-doc.html @@ -2,9 +2,9 @@ - + API Help - + diff --git a/reference/index-files/index-1.html b/reference/index-files/index-1.html index 3ddc365..1e5d233 100644 --- a/reference/index-files/index-1.html +++ b/reference/index-files/index-1.html @@ -2,9 +2,9 @@ - + A-Index - + @@ -146,9 +146,9 @@

    A

     
    active(boolean) - Method in class teilchen.force.Attractor
     
    -
    active() - Method in class teilchen.force.flowfield.FlowField
    +
    active() - Method in class teilchen.force.FlowField
     
    -
    active(boolean) - Method in class teilchen.force.flowfield.FlowField
    +
    active(boolean) - Method in class teilchen.force.FlowField
     
    active() - Method in class teilchen.force.Gravity
     
    @@ -178,9 +178,9 @@

    A

     
    active(boolean) - Method in class teilchen.force.TriangleDeflector
     
    -
    active() - Method in class teilchen.force.vectorfield.VectorField
    +
    active() - Method in class teilchen.force.VectorField
     
    -
    active(boolean) - Method in class teilchen.force.vectorfield.VectorField
    +
    active(boolean) - Method in class teilchen.force.VectorField
     
    active() - Method in class teilchen.force.ViscousDrag
     
    @@ -210,7 +210,7 @@

    A

     
    addConstraints(ArrayList<? extends IConstraint>) - Method in class teilchen.Physics
     
    -
    addForce(FlowFieldForce) - Method in class teilchen.force.flowfield.FlowField
    +
    addForce(FlowFieldForce) - Method in class teilchen.force.FlowField
     
    addForces(ArrayList<? extends IForce>) - Method in class teilchen.Physics
     
    @@ -282,7 +282,7 @@

    A

     
    apply(float, Physics) - Method in class teilchen.force.DirectedAttractor
     
    -
    apply(float, Physics) - Method in class teilchen.force.flowfield.FlowField
    +
    apply(float, Physics) - Method in class teilchen.force.FlowField
     
    apply(float, Physics) - Method in class teilchen.force.Gravity
     
    @@ -302,7 +302,7 @@

    A

     
    apply(float, Physics) - Method in class teilchen.force.TriangleDeflector
     
    -
    apply(float, Physics) - Method in class teilchen.force.vectorfield.VectorField
    +
    apply(float, Physics) - Method in class teilchen.force.VectorField
     
    apply(float, Physics) - Method in class teilchen.force.ViscousDrag
     
    @@ -310,9 +310,9 @@

    A

     
    apply(Physics) - Method in class teilchen.util.CollisionManager.CollisionStick
     
    -
    applyForce(FlowField) - Method in class teilchen.force.flowfield.FlowFieldForce
    +
    applyForce(FlowField) - Method in class teilchen.force.FlowFieldForce
     
    -
    applyForce(FlowField) - Method in class teilchen.force.flowfield.FlowFieldForceMOUSE
    +
    applyForce(FlowField) - Method in class teilchen.force.FlowFieldForceMOUSE
     
    applyForces(float) - Method in class teilchen.Physics
     
    diff --git a/reference/index-files/index-10.html b/reference/index-files/index-10.html index ea0b929..8d8d5eb 100644 --- a/reference/index-files/index-10.html +++ b/reference/index-files/index-10.html @@ -2,9 +2,9 @@ - + L-Index - + @@ -107,7 +107,7 @@

    L

    from paul bourke ( http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline3d/ )
    -
    loop(float) - Method in class teilchen.force.flowfield.FlowField
    +
    loop(float) - Method in class teilchen.force.FlowField
     
    loop(float, int) - Method in class teilchen.Physics
     
    diff --git a/reference/index-files/index-11.html b/reference/index-files/index-11.html index 12da304..8a88f01 100644 --- a/reference/index-files/index-11.html +++ b/reference/index-files/index-11.html @@ -2,9 +2,9 @@ - + M-Index - + @@ -160,6 +160,10 @@

    M

     
    minimumDistance() - Method in class teilchen.util.CollisionManager
     
    +
    MortalParticle - Class in teilchen
    +
     
    +
    MortalParticle() - Constructor for class teilchen.MortalParticle
    +
     
    Motor - Class in teilchen.behavior
     
    Motor() - Constructor for class teilchen.behavior.Motor
    diff --git a/reference/index-files/index-12.html b/reference/index-files/index-12.html index fadcdaf..12899a0 100644 --- a/reference/index-files/index-12.html +++ b/reference/index-files/index-12.html @@ -2,9 +2,9 @@ - + N-Index - + @@ -72,7 +72,7 @@

    N

    -
    n - Variable in class teilchen.force.flowfield.FlowField
    +
    n - Variable in class teilchen.force.FlowField
     
    NEGATIVE_X - Variable in class teilchen.constraint.ReflectBox
     
    diff --git a/reference/index-files/index-13.html b/reference/index-files/index-13.html index 6913a02..98cc135 100644 --- a/reference/index-files/index-13.html +++ b/reference/index-files/index-13.html @@ -2,9 +2,9 @@ - + O-Index - + diff --git a/reference/index-files/index-14.html b/reference/index-files/index-14.html index a38a076..1b2f747 100644 --- a/reference/index-files/index-14.html +++ b/reference/index-files/index-14.html @@ -2,9 +2,9 @@ - + P-Index - + @@ -142,9 +142,9 @@

    P

    position() - Method in class teilchen.force.Attractor
     
    -
    position() - Method in class teilchen.force.flowfield.FlowField
    +
    position() - Method in class teilchen.force.FlowField
     
    -
    position - Variable in class teilchen.force.flowfield.FlowFieldForce
    +
    position - Variable in class teilchen.force.FlowFieldForce
     
    position() - Method in interface teilchen.Particle
     
    diff --git a/reference/index-files/index-15.html b/reference/index-files/index-15.html index c85a852..cee7ae0 100644 --- a/reference/index-files/index-15.html +++ b/reference/index-files/index-15.html @@ -2,9 +2,9 @@ - + R-Index - + @@ -105,7 +105,7 @@

    R

    range(float, float) - Method in class teilchen.constraint.Angular
     
    -
    range - Variable in class teilchen.force.flowfield.FlowFieldForce
    +
    range - Variable in class teilchen.force.FlowFieldForce
     
    Ray3f - Class in teilchen.util
     
    @@ -154,7 +154,7 @@

    R

     
    removeTags() - Method in class teilchen.Physics
     
    -
    reset() - Method in class teilchen.force.flowfield.FlowField
    +
    reset() - Method in class teilchen.force.FlowField
     
    RESOLVE_SAME_PLACE - Static variable in class teilchen.util.Overlap
     
    diff --git a/reference/index-files/index-16.html b/reference/index-files/index-16.html index 909d490..4e14727 100644 --- a/reference/index-files/index-16.html +++ b/reference/index-files/index-16.html @@ -2,9 +2,9 @@ - + S-Index - + @@ -74,7 +74,7 @@

    S

    satisfyNeighborConstraints(ArrayList<Particle>, float) - Static method in class teilchen.util.Util
     
    -
    scale() - Method in class teilchen.force.flowfield.FlowField
    +
    scale() - Method in class teilchen.force.FlowField
     
    scale(float, Vector4f) - Method in class teilchen.util.Vector4f
     
    @@ -128,15 +128,15 @@

    S

     
    set(PVector) - Method in class teilchen.util.Vector4f
     
    -
    setAcceleration(PVector) - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    setAcceleration(PVector) - Method in class teilchen.force.VectorFieldUnit
     
    setDirectionRef(PVector) - Method in class teilchen.behavior.Motor
     
    -
    setForce() - Method in class teilchen.force.flowfield.FlowField
    +
    setForce() - Method in class teilchen.force.FlowField
     
    -
    setForce(float, float, PVector, float) - Method in class teilchen.force.flowfield.FlowField
    +
    setForce(float, float, PVector, float) - Method in class teilchen.force.FlowField
     
    -
    setForceArea(float[][], int, int, float, float) - Method in class teilchen.force.flowfield.FlowField
    +
    setForceArea(float[][], int, int, float, float) - Method in class teilchen.force.FlowField
     
    setIdentity() - Method in class teilchen.util.Matrix3f
     
    @@ -156,11 +156,11 @@

    S

     
    setParticleClass(Class<T>) - Method in class teilchen.util.ParticleTrail
     
    -
    setPosition(PVector) - Method in class teilchen.force.flowfield.FlowFieldForceMOUSE
    +
    setPosition(PVector) - Method in class teilchen.force.FlowFieldForceMOUSE
     
    -
    setPosition(PVector) - Method in class teilchen.force.vectorfield.VectorField
    +
    setPosition(PVector) - Method in class teilchen.force.VectorField
     
    -
    setPosition(PVector) - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    setPosition(PVector) - Method in class teilchen.force.VectorFieldUnit
     
    setPositionRef(PVector) - Method in class teilchen.BasicParticle
     
    @@ -186,9 +186,9 @@

    S

     
    setRotationIdentity() - Method in class teilchen.util.TransformMatrix4f
     
    -
    setScale(PVector) - Method in class teilchen.force.vectorfield.VectorField
    +
    setScale(PVector) - Method in class teilchen.force.VectorField
     
    -
    setScale(PVector) - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    setScale(PVector) - Method in class teilchen.force.VectorFieldUnit
     
    setScale(PVector) - Method in class teilchen.util.Matrix3f
     
    @@ -222,9 +222,9 @@

    S

     
    ShortLivedParticle() - Constructor for class teilchen.ShortLivedParticle
     
    -
    showHair - Variable in class teilchen.force.flowfield.FlowField
    +
    showHair - Variable in class teilchen.force.FlowField
     
    -
    showVelocity - Variable in class teilchen.force.flowfield.FlowField
    +
    showVelocity - Variable in class teilchen.force.FlowField
     
    size() - Method in class teilchen.cubicle.CubicleAtom
     
    @@ -316,17 +316,13 @@

    S

     
    strength(float) - Method in class teilchen.force.Attractor
     
    -
    strength - Variable in class teilchen.force.flowfield.FlowFieldForce
    +
    strength - Variable in class teilchen.force.FlowFieldForce
     
    strength() - Method in class teilchen.force.Spring
    -
    -
    spring constant.
    -
    +
     
    strength(float) - Method in class teilchen.force.Spring
    -
    -
    spring constant.
    -
    -
    strength - Variable in class teilchen.force.vectorfield.VectorField
    +
     
    +
    strength - Variable in class teilchen.force.VectorField
     
    sub(Matrix3f, Matrix3f) - Method in class teilchen.util.Matrix3f
     
    diff --git a/reference/index-files/index-17.html b/reference/index-files/index-17.html index 7727462..72a214f 100644 --- a/reference/index-files/index-17.html +++ b/reference/index-files/index-17.html @@ -2,9 +2,9 @@ - + T-Index - + @@ -102,10 +102,6 @@

    T

     
    teilchen.force - package teilchen.force
     
    -
    teilchen.force.flowfield - package teilchen.force.flowfield
    -
     
    -
    teilchen.force.vectorfield - package teilchen.force.vectorfield
    -
     
    teilchen.integration - package teilchen.integration
     
    teilchen.util - package teilchen.util
    @@ -138,7 +134,7 @@

    T

     
    transform() - Method in class teilchen.cubicle.CubicleWorld
     
    -
    transform() - Method in class teilchen.force.flowfield.FlowField
    +
    transform() - Method in class teilchen.force.FlowField
     
    transform(PVector) - Method in class teilchen.util.Matrix3f
     
    diff --git a/reference/index-files/index-18.html b/reference/index-files/index-18.html index a2b785f..cdae20c 100644 --- a/reference/index-files/index-18.html +++ b/reference/index-files/index-18.html @@ -2,9 +2,9 @@ - + U-Index - + @@ -72,7 +72,7 @@

    U

    -
    u() - Method in class teilchen.force.flowfield.FlowField
    +
    u() - Method in class teilchen.force.FlowField
     
    u - Variable in class teilchen.util.Intersection.IntersectionResult
     
    diff --git a/reference/index-files/index-19.html b/reference/index-files/index-19.html index fdadbc6..286cd33 100644 --- a/reference/index-files/index-19.html +++ b/reference/index-files/index-19.html @@ -2,9 +2,9 @@ - + V-Index - + @@ -72,7 +72,7 @@

    V

    -
    v() - Method in class teilchen.force.flowfield.FlowField
    +
    v() - Method in class teilchen.force.FlowField
     
    v - Variable in class teilchen.util.Intersection.IntersectionResult
     
    @@ -123,33 +123,33 @@

    V

     
    vectorB - Variable in class teilchen.util.Plane3f
     
    -
    VectorField - Class in teilchen.force.vectorfield
    +
    VectorField - Class in teilchen.force
     
    -
    VectorField(VectorFieldGenerator) - Constructor for class teilchen.force.vectorfield.VectorField
    +
    VectorField(VectorFieldGenerator) - Constructor for class teilchen.force.VectorField
     
    -
    VectorFieldGenerator - Interface in teilchen.force.vectorfield
    +
    VectorFieldGenerator - Interface in teilchen.force
     
    -
    VectorFieldGeneratorAVERAGEUNITS - Class in teilchen.force.vectorfield
    +
    VectorFieldGeneratorAVERAGEUNITS - Class in teilchen.force
     
    -
    VectorFieldGeneratorAVERAGEUNITS(int, int, int, PVector[], PVector[]) - Constructor for class teilchen.force.vectorfield.VectorFieldGeneratorAVERAGEUNITS
    +
    VectorFieldGeneratorAVERAGEUNITS(int, int, int, PVector[], PVector[]) - Constructor for class teilchen.force.VectorFieldGeneratorAVERAGEUNITS
     
    -
    VectorFieldGeneratorRANDOM - Class in teilchen.force.vectorfield
    +
    VectorFieldGeneratorRANDOM - Class in teilchen.force
     
    -
    VectorFieldGeneratorRANDOM(int, int, int) - Constructor for class teilchen.force.vectorfield.VectorFieldGeneratorRANDOM
    +
    VectorFieldGeneratorRANDOM(int, int, int) - Constructor for class teilchen.force.VectorFieldGeneratorRANDOM
     
    VectorfieldParticle - Class in teilchen
     
    VectorfieldParticle() - Constructor for class teilchen.VectorfieldParticle
     
    -
    VectorFieldUnit - Class in teilchen.force.vectorfield
    +
    VectorFieldUnit - Class in teilchen.force
     
    -
    VectorFieldUnit(PVector, PVector, PVector) - Constructor for class teilchen.force.vectorfield.VectorFieldUnit
    +
    VectorFieldUnit(PVector, PVector, PVector) - Constructor for class teilchen.force.VectorFieldUnit
     
    velocity() - Method in class teilchen.BasicParticle
     
    velocity() - Method in interface teilchen.Particle
     
    -
    velocityBrushSize - Variable in class teilchen.force.flowfield.FlowField
    +
    velocityBrushSize - Variable in class teilchen.force.FlowField
     
    Verhalten - Interface in teilchen.behavior
     
    diff --git a/reference/index-files/index-2.html b/reference/index-files/index-2.html index c84ad67..96a4569 100644 --- a/reference/index-files/index-2.html +++ b/reference/index-files/index-2.html @@ -2,9 +2,9 @@ - + B-Index - + diff --git a/reference/index-files/index-20.html b/reference/index-files/index-20.html index 8db5bf4..5fbc96e 100644 --- a/reference/index-files/index-20.html +++ b/reference/index-files/index-20.html @@ -2,9 +2,9 @@ - + W-Index - + diff --git a/reference/index-files/index-21.html b/reference/index-files/index-21.html index 98b6bdb..37f2653 100644 --- a/reference/index-files/index-21.html +++ b/reference/index-files/index-21.html @@ -2,9 +2,9 @@ - + X-Index - + diff --git a/reference/index-files/index-22.html b/reference/index-files/index-22.html index 8e712b2..e2e546b 100644 --- a/reference/index-files/index-22.html +++ b/reference/index-files/index-22.html @@ -2,9 +2,9 @@ - + Y-Index - + diff --git a/reference/index-files/index-23.html b/reference/index-files/index-23.html index adb9cc2..5a5c69c 100644 --- a/reference/index-files/index-23.html +++ b/reference/index-files/index-23.html @@ -2,9 +2,9 @@ - + Z-Index - + diff --git a/reference/index-files/index-3.html b/reference/index-files/index-3.html index 8c0306a..2a205ab 100644 --- a/reference/index-files/index-3.html +++ b/reference/index-files/index-3.html @@ -2,9 +2,9 @@ - + C-Index - + @@ -78,9 +78,9 @@

    C

     
    c - Variable in class teilchen.util.StableStickQuad
     
    -
    calculateDensity - Variable in class teilchen.force.flowfield.FlowField
    +
    calculateDensity - Variable in class teilchen.force.FlowField
     
    -
    calculateDensity() - Method in class teilchen.force.flowfield.FlowField
    +
    calculateDensity() - Method in class teilchen.force.FlowField
     
    calculateDerivatives(List<Particle>, List<Derivate3f>) - Static method in class teilchen.integration.IntegrationUtil
     
    @@ -96,9 +96,9 @@

    C

     
    calculateReflectionVector(Particle, PVector) - Static method in class teilchen.util.Util
     
    -
    calculateVelocity - Variable in class teilchen.force.flowfield.FlowField
    +
    calculateVelocity - Variable in class teilchen.force.FlowField
     
    -
    calculateVelocity() - Method in class teilchen.force.flowfield.FlowField
    +
    calculateVelocity() - Method in class teilchen.force.FlowField
     
    cd - Variable in class teilchen.util.StableSpringQuad
     
    @@ -181,12 +181,6 @@

    C

     
    compareTo(Vector3i) - Method in class teilchen.util.Vector3i
     
    -
    condition() - Method in class teilchen.ConditionalParticle
    -
     
    -
    ConditionalParticle - Class in teilchen
    -
     
    -
    ConditionalParticle() - Constructor for class teilchen.ConditionalParticle
    -
     
    constrain_iterations_per_steps - Variable in class teilchen.Physics
     
    constraints() - Method in class teilchen.Physics
    diff --git a/reference/index-files/index-4.html b/reference/index-files/index-4.html index f6dfb42..eff6112 100644 --- a/reference/index-files/index-4.html +++ b/reference/index-files/index-4.html @@ -2,9 +2,9 @@ - + D-Index - + @@ -100,21 +100,19 @@

    D

     
    data() - Method in class teilchen.cubicle.CubicleAtom
     
    -
    data() - Method in class teilchen.force.vectorfield.VectorField
    +
    data() - Method in class teilchen.force.VectorField
     
    -
    data() - Method in interface teilchen.force.vectorfield.VectorFieldGenerator
    +
    data() - Method in interface teilchen.force.VectorFieldGenerator
     
    -
    data() - Method in class teilchen.force.vectorfield.VectorFieldGeneratorAVERAGEUNITS
    +
    data() - Method in class teilchen.force.VectorFieldGeneratorAVERAGEUNITS
     
    -
    data() - Method in class teilchen.force.vectorfield.VectorFieldGeneratorRANDOM
    +
    data() - Method in class teilchen.force.VectorFieldGeneratorRANDOM
     
    dead() - Method in class teilchen.BasicParticle
     
    -
    dead() - Method in class teilchen.ConditionalParticle
    -
     
    dead() - Method in class teilchen.force.Attractor
     
    -
    dead() - Method in class teilchen.force.flowfield.FlowField
    +
    dead() - Method in class teilchen.force.FlowField
     
    dead() - Method in class teilchen.force.Gravity
     
    @@ -132,17 +130,19 @@

    D

     
    dead() - Method in class teilchen.force.TriangleDeflector
     
    -
    dead() - Method in class teilchen.force.vectorfield.VectorField
    +
    dead() - Method in class teilchen.force.VectorField
     
    dead() - Method in class teilchen.force.ViscousDrag
     
    +
    dead() - Method in class teilchen.MortalParticle
    +
     
    dead() - Method in interface teilchen.Particle
     
    dead() - Method in class teilchen.ShortLivedParticle
     
    DEBUG_VIEW - Variable in class teilchen.constraint.LineIntersectionConstraint
     
    -
    deltatime - Variable in class teilchen.force.flowfield.FlowField
    +
    deltatime - Variable in class teilchen.force.FlowField
     
    Derivate3f - Class in teilchen.integration
     
    diff --git a/reference/index-files/index-5.html b/reference/index-files/index-5.html index e72aad3..31be04c 100644 --- a/reference/index-files/index-5.html +++ b/reference/index-files/index-5.html @@ -2,9 +2,9 @@ - + E-Index - + diff --git a/reference/index-files/index-6.html b/reference/index-files/index-6.html index 9ef220d..7ca11d3 100644 --- a/reference/index-files/index-6.html +++ b/reference/index-files/index-6.html @@ -2,9 +2,9 @@ - + F-Index - + @@ -90,19 +90,19 @@

    F

     
    FLOAT(float, float) - Static method in class teilchen.util.Random
     
    -
    FlowField - Class in teilchen.force.flowfield
    +
    FlowField - Class in teilchen.force
     
    -
    FlowField() - Constructor for class teilchen.force.flowfield.FlowField
    +
    FlowField() - Constructor for class teilchen.force.FlowField
     
    -
    FlowField(int, int, PVector) - Constructor for class teilchen.force.flowfield.FlowField
    +
    FlowField(int, int, PVector) - Constructor for class teilchen.force.FlowField
     
    -
    FlowFieldForce - Class in teilchen.force.flowfield
    +
    FlowFieldForce - Class in teilchen.force
     
    -
    FlowFieldForce() - Constructor for class teilchen.force.flowfield.FlowFieldForce
    +
    FlowFieldForce() - Constructor for class teilchen.force.FlowFieldForce
     
    -
    FlowFieldForceMOUSE - Class in teilchen.force.flowfield
    +
    FlowFieldForceMOUSE - Class in teilchen.force
     
    -
    FlowFieldForceMOUSE() - Constructor for class teilchen.force.flowfield.FlowFieldForceMOUSE
    +
    FlowFieldForceMOUSE() - Constructor for class teilchen.force.FlowFieldForceMOUSE
     
    force() - Method in class teilchen.BasicParticle
     
    @@ -132,13 +132,13 @@

    F

     
    force() - Method in interface teilchen.Particle
     
    -
    forces() - Method in class teilchen.force.flowfield.FlowField
    +
    forces() - Method in class teilchen.force.FlowField
     
    forces() - Method in class teilchen.Physics
     
    forces(int) - Method in class teilchen.Physics
     
    -
    forceScale - Variable in class teilchen.force.flowfield.FlowField
    +
    forceScale - Variable in class teilchen.force.FlowField
     
    fragments() - Method in class teilchen.util.ParticleTrail
     
    diff --git a/reference/index-files/index-7.html b/reference/index-files/index-7.html index e72c3d8..ba2fb1d 100644 --- a/reference/index-files/index-7.html +++ b/reference/index-files/index-7.html @@ -2,9 +2,9 @@ - + G-Index - + @@ -72,7 +72,7 @@

    G

    -
    getAcceleration() - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    getAcceleration() - Method in class teilchen.force.VectorFieldUnit
     
    getAtom(int, int, int) - Method in class teilchen.cubicle.CubicleWorld
     
    @@ -89,7 +89,7 @@

    G

    getFloat() - Method in class teilchen.util.Random
     
    -
    getForce(PVector) - Method in class teilchen.force.flowfield.FlowField
    +
    getForce(PVector) - Method in class teilchen.force.FlowField
     
    getInt(int, int) - Method in class teilchen.util.Random
    @@ -113,13 +113,13 @@

    G

     
    getOffWorldAtom() - Method in class teilchen.cubicle.CubicleWorld
     
    -
    getPosition() - Method in class teilchen.force.vectorfield.VectorField
    +
    getPosition() - Method in class teilchen.force.VectorField
     
    -
    getPosition() - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    getPosition() - Method in class teilchen.force.VectorFieldUnit
     
    -
    getScale() - Method in class teilchen.force.vectorfield.VectorField
    +
    getScale() - Method in class teilchen.force.VectorField
     
    -
    getScale() - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    getScale() - Method in class teilchen.force.VectorFieldUnit
     
    getVector3f(float, float) - Method in class teilchen.util.Random
     
    diff --git a/reference/index-files/index-8.html b/reference/index-files/index-8.html index f520331..3824478 100644 --- a/reference/index-files/index-8.html +++ b/reference/index-files/index-8.html @@ -2,9 +2,9 @@ - + H-Index - + diff --git a/reference/index-files/index-9.html b/reference/index-files/index-9.html index d11c4f2..5de760c 100644 --- a/reference/index-files/index-9.html +++ b/reference/index-files/index-9.html @@ -2,9 +2,9 @@ - + I-Index - + @@ -145,7 +145,9 @@

    I

    entities can be temporarily removed from the process of being updated by the world.
    -
    isInside(PVector) - Method in class teilchen.force.vectorfield.VectorFieldUnit
    +
    isDead() - Method in class teilchen.MortalParticle
    +
     
    +
    isInside(PVector) - Method in class teilchen.force.VectorFieldUnit
     
    isNaN(PVector) - Static method in class teilchen.util.Util
     
    diff --git a/reference/index.html b/reference/index.html index 4dc570d..364ed86 100644 --- a/reference/index.html +++ b/reference/index.html @@ -2,7 +2,7 @@ - + Generated Documentation (Untitled) @@ -18,8 +18,6 @@

    Packages

  • teilchen.constraint
  • teilchen.cubicle
  • teilchen.force
  • -
  • teilchen.force.flowfield
  • -
  • teilchen.force.vectorfield
  • teilchen.integration
  • teilchen.util
  • diff --git a/reference/overview-summary.html b/reference/overview-summary.html index e0e4970..8d6de66 100644 --- a/reference/overview-summary.html +++ b/reference/overview-summary.html @@ -2,9 +2,9 @@ - + Overview - + @@ -96,14 +96,6 @@   -teilchen.force.flowfield -  - - -teilchen.force.vectorfield -  - - teilchen.integration   diff --git a/reference/overview-tree.html b/reference/overview-tree.html index 6f14905..939a59c 100644 --- a/reference/overview-tree.html +++ b/reference/overview-tree.html @@ -2,9 +2,9 @@ - + Class Hierarchy - + @@ -76,8 +76,6 @@

    Hierarchy For All Packages

  • teilchen.constraint,
  • teilchen.cubicle,
  • teilchen.force,
  • -
  • teilchen.force.flowfield,
  • -
  • teilchen.force.vectorfield,
  • teilchen.integration,
  • teilchen.util
  • @@ -98,8 +96,8 @@

    Class Hierarchy

  • teilchen.BasicParticle (implements teilchen.Particle, java.io.Serializable) @@ -115,10 +113,10 @@

    Class Hierarchy

  • teilchen.util.DrawLib
  • teilchen.integration.Euler (implements teilchen.integration.IIntegrator)
  • teilchen.behavior.Flee (implements teilchen.behavior.IBehavior, teilchen.behavior.Verhalten)
  • -
  • teilchen.force.flowfield.FlowField (implements teilchen.force.IForce)
  • -
  • teilchen.force.flowfield.FlowFieldForce +
  • teilchen.force.FlowField (implements teilchen.force.IForce)
  • +
  • teilchen.force.FlowFieldForce
  • teilchen.force.Gravity (implements teilchen.force.IForce)
  • @@ -176,10 +174,10 @@

    Class Hierarchy

  • teilchen.behavior.Util.ProximityStructure
  • teilchen.util.Vector3i (implements java.lang.Comparable<T>, java.io.Serializable)
  • teilchen.util.Vector4f (implements java.io.Serializable)
  • -
  • teilchen.force.vectorfield.VectorField (implements teilchen.force.IForce)
  • -
  • teilchen.force.vectorfield.VectorFieldGeneratorAVERAGEUNITS (implements teilchen.force.vectorfield.VectorFieldGenerator)
  • -
  • teilchen.force.vectorfield.VectorFieldGeneratorRANDOM (implements teilchen.force.vectorfield.VectorFieldGenerator)
  • -
  • teilchen.force.vectorfield.VectorFieldUnit
  • +
  • teilchen.force.VectorField (implements teilchen.force.IForce)
  • +
  • teilchen.force.VectorFieldGeneratorAVERAGEUNITS (implements teilchen.force.VectorFieldGenerator)
  • +
  • teilchen.force.VectorFieldGeneratorRANDOM (implements teilchen.force.VectorFieldGenerator)
  • +
  • teilchen.force.VectorFieldUnit
  • teilchen.integration.Verlet (implements teilchen.integration.IIntegrator)
  • teilchen.force.ViscousDrag (implements teilchen.force.IForce)
  • teilchen.behavior.Wander (implements teilchen.behavior.IBehavior)
  • @@ -210,7 +208,7 @@

    Interface Hierarchy

    -
  • teilchen.force.vectorfield.VectorFieldGenerator
  • +
  • teilchen.force.VectorFieldGenerator
  • Enum Hierarchy

    Direct Known Subclasses:
    -
    BehaviorParticle, ConditionalParticle, CubicleParticle, ShortLivedParticle, VectorfieldParticle
    +
    BehaviorParticle, CubicleParticle, MortalParticle, ShortLivedParticle, VectorfieldParticle


    diff --git a/reference/teilchen/BehaviorParticle.html b/reference/teilchen/BehaviorParticle.html index 437acaf..47c4d43 100644 --- a/reference/teilchen/BehaviorParticle.html +++ b/reference/teilchen/BehaviorParticle.html @@ -2,9 +2,9 @@ - + BehaviorParticle - + @@ -48,7 +48,7 @@
    All Known Implementing Classes:
    -
    BasicParticle, BehaviorParticle, ConditionalParticle, CubicleParticle, Packing.PackingEntity, ShortLivedParticle, VectorfieldParticle
    +
    BasicParticle, BehaviorParticle, CubicleParticle, MortalParticle, Packing.PackingEntity, ShortLivedParticle, VectorfieldParticle


    diff --git a/reference/teilchen/util/StableSpringQuad.html b/reference/teilchen/util/StableSpringQuad.html index 4f77728..ec0ccc1 100644 --- a/reference/teilchen/util/StableSpringQuad.html +++ b/reference/teilchen/util/StableSpringQuad.html @@ -2,9 +2,9 @@ - + StableSpringQuad - + diff --git a/reference/teilchen/util/StableStickQuad.html b/reference/teilchen/util/StableStickQuad.html index 078ae2c..4657d4d 100644 --- a/reference/teilchen/util/StableStickQuad.html +++ b/reference/teilchen/util/StableStickQuad.html @@ -2,9 +2,9 @@ - + StableStickQuad - + diff --git a/reference/teilchen/util/StickMan.html b/reference/teilchen/util/StickMan.html index a99b27a..9619f46 100644 --- a/reference/teilchen/util/StickMan.html +++ b/reference/teilchen/util/StickMan.html @@ -2,9 +2,9 @@ - + StickMan - + diff --git a/reference/teilchen/util/TransformMatrix4f.html b/reference/teilchen/util/TransformMatrix4f.html index 83af6ae..19e5ddb 100644 --- a/reference/teilchen/util/TransformMatrix4f.html +++ b/reference/teilchen/util/TransformMatrix4f.html @@ -2,9 +2,9 @@ - + TransformMatrix4f - + diff --git a/reference/teilchen/util/Util.html b/reference/teilchen/util/Util.html index 85d327b..184f4a7 100644 --- a/reference/teilchen/util/Util.html +++ b/reference/teilchen/util/Util.html @@ -2,9 +2,9 @@ - + Util - + diff --git a/reference/teilchen/util/Vector3i.html b/reference/teilchen/util/Vector3i.html index 5067f21..e5dc819 100644 --- a/reference/teilchen/util/Vector3i.html +++ b/reference/teilchen/util/Vector3i.html @@ -2,9 +2,9 @@ - + Vector3i - + diff --git a/reference/teilchen/util/Vector4f.html b/reference/teilchen/util/Vector4f.html index 0bd589d..96682c8 100644 --- a/reference/teilchen/util/Vector4f.html +++ b/reference/teilchen/util/Vector4f.html @@ -2,9 +2,9 @@ - + Vector4f - + diff --git a/reference/teilchen/util/WorldAxisAlignedBoundingBox.html b/reference/teilchen/util/WorldAxisAlignedBoundingBox.html index c63f0dd..163b2ba 100644 --- a/reference/teilchen/util/WorldAxisAlignedBoundingBox.html +++ b/reference/teilchen/util/WorldAxisAlignedBoundingBox.html @@ -2,9 +2,9 @@ - + WorldAxisAlignedBoundingBox - + diff --git a/reference/teilchen/util/package-frame.html b/reference/teilchen/util/package-frame.html index 7330f3e..8560f69 100644 --- a/reference/teilchen/util/package-frame.html +++ b/reference/teilchen/util/package-frame.html @@ -2,9 +2,9 @@ - + teilchen.util - + diff --git a/reference/teilchen/util/package-summary.html b/reference/teilchen/util/package-summary.html index 106432b..68b66ea 100644 --- a/reference/teilchen/util/package-summary.html +++ b/reference/teilchen/util/package-summary.html @@ -2,9 +2,9 @@ - + teilchen.util - + diff --git a/reference/teilchen/util/package-tree.html b/reference/teilchen/util/package-tree.html index e317c27..c2cdea1 100644 --- a/reference/teilchen/util/package-tree.html +++ b/reference/teilchen/util/package-tree.html @@ -2,9 +2,9 @@ - + teilchen.util Class Hierarchy - + diff --git a/src/teilchen/BasicParticle.java b/src/teilchen/BasicParticle.java index dc4cdca..9d0f10a 100755 --- a/src/teilchen/BasicParticle.java +++ b/src/teilchen/BasicParticle.java @@ -19,36 +19,27 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; -import java.io.Serializable; import processing.core.PVector; -public class BasicParticle - implements Particle, Serializable { - - private boolean mFixed; - - private float mAge; - - private float mMass; +import java.io.Serializable; - private PVector mPosition; +public class BasicParticle implements Particle, Serializable { + private static final long serialVersionUID = 3737917975116369338L; private final PVector mOldPosition; - private final PVector mVelocity; - private final PVector mForce; - + private boolean mFixed; + private float mAge; + private float mMass; + private PVector mPosition; private boolean mTagged; - private boolean mStill; - private float mRadius; - private static final long serialVersionUID = 3737917975116369338L; - public BasicParticle() { mPosition = new PVector(); mOldPosition = new PVector(); @@ -86,10 +77,6 @@ public void mass(float pMass) { mMass = pMass; } - public PVector position() { - return mPosition; - } - public PVector old_position() { return mOldPosition; } @@ -110,9 +97,6 @@ public boolean dead() { return false; } - public void accumulateInnerForce(final float pDeltaTime) { - } - public boolean tagged() { return mTagged; } @@ -121,19 +105,26 @@ public void tag(boolean pTag) { mTagged = pTag; } - public boolean still() { - return mStill; - } - - public void still(boolean pStill) { - mStill = pStill; + public void accumulateInnerForce(final float pDeltaTime) { } public float radius() { return mRadius; } + public PVector position() { + return mPosition; + } + public void radius(float pRadius) { mRadius = pRadius; } + + public boolean still() { + return mStill; + } + + public void still(boolean pStill) { + mStill = pStill; + } } diff --git a/src/teilchen/BehaviorParticle.java b/src/teilchen/BehaviorParticle.java index 522b31c..31d56fb 100755 --- a/src/teilchen/BehaviorParticle.java +++ b/src/teilchen/BehaviorParticle.java @@ -61,8 +61,8 @@ public float maximumInnerForce() { return mMaximumInnerForce; } - public void maximumInnerForce(float theForce) { - mMaximumInnerForce = theForce; + public void maximumInnerForce(float pForce) { + mMaximumInnerForce = pForce; } public ArrayList behaviors() { diff --git a/src/teilchen/IBehaviorParticle.java b/src/teilchen/IBehaviorParticle.java index 2c3252c..3a23265 100755 --- a/src/teilchen/IBehaviorParticle.java +++ b/src/teilchen/IBehaviorParticle.java @@ -28,7 +28,7 @@ public interface IBehaviorParticle float maximumInnerForce(); - void maximumInnerForce(float theForce); + void maximumInnerForce(float pForce); ArrayList behaviors(); } diff --git a/processing-library/teilchen/src/teilchen/ConditionalParticle.java b/src/teilchen/MortalParticle.java similarity index 86% rename from processing-library/teilchen/src/teilchen/ConditionalParticle.java rename to src/teilchen/MortalParticle.java index c10d634..8adbbaa 100755 --- a/processing-library/teilchen/src/teilchen/ConditionalParticle.java +++ b/src/teilchen/MortalParticle.java @@ -19,14 +19,14 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; -public abstract class ConditionalParticle - extends BasicParticle { +public abstract class MortalParticle extends BasicParticle { public boolean dead() { - return !condition(); + return isDead(); } - public abstract boolean condition(); + public abstract boolean isDead(); } diff --git a/src/teilchen/Particle.java b/src/teilchen/Particle.java index 2b91ef2..28cfdec 100755 --- a/src/teilchen/Particle.java +++ b/src/teilchen/Particle.java @@ -19,6 +19,7 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; import processing.core.PVector; @@ -39,8 +40,6 @@ public interface Particle void mass(float pMass); - PVector position(); - PVector old_position(); void setPositionRef(PVector pPosition); @@ -59,6 +58,8 @@ public interface Particle float radius(); + PVector position(); + void radius(float pRadius); boolean still(); diff --git a/src/teilchen/Physics.java b/src/teilchen/Physics.java index 0335fae..c6b32cb 100755 --- a/src/teilchen/Physics.java +++ b/src/teilchen/Physics.java @@ -62,30 +62,30 @@ public void add(Particle theParticle) { mParticles.add(theParticle); } - public void add(Collection theParticles) { - mParticles.addAll(theParticles); + public void add(Collection pParticles) { + mParticles.addAll(pParticles); } public void remove(Particle theParticle) { mParticles.remove(theParticle); } - public void remove(Collection theParticles) { + public void remove(Collection pParticles) { - mParticles.removeAll(theParticles); + mParticles.removeAll(pParticles); } public ArrayList particles() { return mParticles; } - public Particle particles(final int theIndex) { - return mParticles.get(theIndex); + public Particle particles(final int pIndex) { + return mParticles.get(pIndex); } - public BasicParticle makeParticle(final PVector thePosition) { + public BasicParticle makeParticle(final PVector pPosition) { BasicParticle myParticle = makeParticle(); - myParticle.setPositionRef(thePosition); + myParticle.setPositionRef(pPosition); myParticle.old_position().set(myParticle.position()); return myParticle; } @@ -126,10 +126,10 @@ public BasicParticle makeParticle(final PVector thePosition, final float pMass) return myParticle; } - public T makeParticle(Class theParticleClass) { + public T makeParticle(Class pParticleClass) { T myParticle; try { - myParticle = theParticleClass.newInstance(); + myParticle = pParticleClass.newInstance(); mParticles.add(myParticle); } catch (Exception ex) { ex.printStackTrace(); @@ -148,14 +148,15 @@ public void removeTags() { /* forces */ public void add(IForce theForce) { if (theForce instanceof ViscousDrag && mIntegrator instanceof Verlet) { - System.err.println("### WARNING / 'viscous drag' might have no effect with 'verlet' integration. use 'Verlet" + "" + - ".damping" + "(float theDamping)' instead."); + System.err.println( + "### WARNING / 'viscous drag' might have no effect with 'verlet' integration. use 'Verlet" + "" + + ".damping" + "(float theDamping)' instead."); } mForces.add(theForce); } - public void addForces(final ArrayList theForces) { - mForces.addAll(theForces); + public void addForces(final ArrayList pForces) { + mForces.addAll(pForces); } public void remove(IForce theForce) { @@ -191,10 +192,10 @@ public void applyForces(final float theDeltaTime) { } } - public T makeForce(Class theForceClass) { + public T makeForce(Class pForceClass) { T myForce; try { - myForce = theForceClass.newInstance(); + myForce = pForceClass.newInstance(); mForces.add(myForce); } catch (Exception ex) { myForce = null; @@ -202,81 +203,84 @@ public T makeForce(Class theForceClass) { return myForce; } - public Spring makeSpring(final Particle theA, final Particle theB) { - Spring mySpring = new Spring(theA, theB); + public Spring makeSpring(final Particle pA, final Particle pB) { + Spring mySpring = new Spring(pA, pB); mForces.add(mySpring); return mySpring; } - public Spring makeSpring(final Particle theA, final Particle theB, final float theRestLength) { - Spring mySpring = new Spring(theA, theB, theRestLength); + public Spring makeSpring(final Particle pA, final Particle pB, final float pRestLength) { + Spring mySpring = new Spring(pA, pB, pRestLength); mForces.add(mySpring); return mySpring; } - public Spring makeSpring(final Particle theA, final Particle theB, final float theSpringConstant, final float theSpringDamping) { - Spring mySpring = new Spring(theA, theB, theSpringConstant, theSpringDamping); + public Spring makeSpring(final Particle pA, + final Particle pB, + final float pSpringConstant, + final float pSpringDamping) { + Spring mySpring = new Spring(pA, pB, pSpringConstant, pSpringDamping); mForces.add(mySpring); return mySpring; } - public Spring makeSpring(final Particle theA, - final Particle theB, - final float theSpringConstant, - final float theSpringDamping, - final float theRestLength) { - Spring mySpring = new Spring(theA, theB, theSpringConstant, theSpringDamping, theRestLength); + public Spring makeSpring(final Particle pA, + final Particle pB, + final float pSpringConstant, + final float pSpringDamping, + final float pRestLength) { + Spring mySpring = new Spring(pA, pB, pSpringConstant, pSpringDamping, pRestLength); mForces.add(mySpring); return mySpring; } /* constraints */ - public void add(final IConstraint theConstraint) { - mConstraints.add(theConstraint); + public void add(final IConstraint pConstraint) { + mConstraints.add(pConstraint); } - public void addConstraints(final ArrayList theConstraints) { - mConstraints.addAll(theConstraints); + public void addConstraints(final ArrayList pConstraints) { + mConstraints.addAll(pConstraints); } - public void remove(final IConstraint theConstraint) { - mConstraints.remove(theConstraint); + public void remove(final IConstraint pConstraint) { + mConstraints.remove(pConstraint); } public ArrayList constraints() { return mConstraints; } - public IConstraint constraints(final int theIndex) { - return mConstraints.get(theIndex); + public IConstraint constraints(final int pIndex) { + return mConstraints.get(pIndex); } /* integration */ - public void setIntegratorRef(IIntegrator theIntegrator) { - mIntegrator = theIntegrator; + public void setIntegratorRef(IIntegrator pIntegrator) { + mIntegrator = pIntegrator; } public IIntegrator getIntegrator() { return mIntegrator; } - public void loop(final float theDeltaTime, final int theIterations) { - for (int i = 0; i < theIterations; i++) { - step(theDeltaTime / (float) theIterations); + public void loop(final float theDeltaTime, final int pIterations) { + for (int i = 0; i < pIterations; i++) { + step(theDeltaTime / (float) pIterations); } } - public void step(final float theDeltaTime) { + public void step(final float pDeltaTime) { handleForces(); - integrate(theDeltaTime); - advance(theDeltaTime); + integrate(pDeltaTime); + advance(pDeltaTime); handleConstraints(); - post(theDeltaTime); + post(pDeltaTime); } - protected synchronized void integrate(float theDeltaTime) { + protected synchronized void integrate(float pDeltaTime) { for (int j = 0; j < integrations_per_steps; j++) { - mIntegrator.step(theDeltaTime / integrations_per_steps, this); + mIntegrator.step(pDeltaTime / integrations_per_steps, this); } } @@ -302,7 +306,7 @@ protected synchronized void handleConstraints() { } } - protected synchronized void advance(float theDeltaTime) { + protected synchronized void advance(float pDeltaTime) { synchronized (mParticles) { final Iterator i = mParticles.iterator(); while (i.hasNext()) { @@ -310,7 +314,7 @@ protected synchronized void advance(float theDeltaTime) { /* clear force */ mParticle.force().set(0, 0, 0); /* age particle */ - mParticle.age(mParticle.age() + theDeltaTime); + mParticle.age(mParticle.age() + pDeltaTime); /* remove dead */ if (HINT_REMOVE_DEAD) { if (mParticle.dead()) { @@ -339,7 +343,7 @@ protected synchronized void advance(float theDeltaTime) { } } - protected synchronized void post(float theDeltaTime) { + protected synchronized void post(float pDeltaTime) { synchronized (mParticles) { for (Particle mParticle : mParticles) { if (mParticle.fixed()) { diff --git a/src/teilchen/ShortLivedParticle.java b/src/teilchen/ShortLivedParticle.java index 2a114f3..38aab7a 100755 --- a/src/teilchen/ShortLivedParticle.java +++ b/src/teilchen/ShortLivedParticle.java @@ -19,30 +19,30 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; -public class ShortLivedParticle - extends BasicParticle { +public class ShortLivedParticle extends BasicParticle { - private float _myMaxAge; + private float mMaxAge; - public ShortLivedParticle(float theMaxAge) { - _myMaxAge = theMaxAge; + public ShortLivedParticle(float pMaxAge) { + mMaxAge = pMaxAge; } public ShortLivedParticle() { this(1); } - public void setMaxAge(float theMaxAge) { - _myMaxAge = theMaxAge; + public void setMaxAge(float pMaxAge) { + mMaxAge = pMaxAge; } public float ageRatio() { - return Math.min(age() / _myMaxAge, 1); + return Math.min(age() / mMaxAge, 1); } public boolean dead() { - return age() >= _myMaxAge; + return age() >= mMaxAge; } } diff --git a/src/teilchen/VectorfieldParticle.java b/src/teilchen/VectorfieldParticle.java index de7786c..aae1289 100755 --- a/src/teilchen/VectorfieldParticle.java +++ b/src/teilchen/VectorfieldParticle.java @@ -19,26 +19,26 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen; import teilchen.util.Vector3i; -public class VectorfieldParticle - extends BasicParticle { +public class VectorfieldParticle extends BasicParticle { - private Vector3i _myLastUnit; + private Vector3i mLastUnit; public VectorfieldParticle() { super(); - _myLastUnit = new Vector3i(); + mLastUnit = new Vector3i(); } - public void setLastUnit(Vector3i theUnit) { - _myLastUnit = theUnit; + public Vector3i getLastUnit() { + return mLastUnit; } - public Vector3i getLastUnit() { - return _myLastUnit; + public void setLastUnit(Vector3i pUnit) { + mLastUnit = pUnit; } public void accumulateInnerForce(final float pDeltaTime) { diff --git a/src/teilchen/examples/SketchLesson00_Particle.java b/src/teilchen/examples/SketchLesson00_Particle.java index 5ee3e75..00c5c87 100755 --- a/src/teilchen/examples/SketchLesson00_Particle.java +++ b/src/teilchen/examples/SketchLesson00_Particle.java @@ -7,7 +7,7 @@ public class SketchLesson00_Particle extends PApplet { /* - * this sketch show how to create a particle system with a single particle in it. + * this sketch demonstrates how to create a particle system with a single particle in it. */ private Physics mPhysics; diff --git a/src/teilchen/examples/SketchLesson01_Gravity.java b/src/teilchen/examples/SketchLesson01_Gravity.java index 603cd25..6ccd03a 100755 --- a/src/teilchen/examples/SketchLesson01_Gravity.java +++ b/src/teilchen/examples/SketchLesson01_Gravity.java @@ -8,7 +8,8 @@ public class SketchLesson01_Gravity extends PApplet { /* - * this sketch show how to create a particle system with a single particle in it. + * this sketch demonstrates how to create a particle system with a single particle in it and a + * gravity force pulling it downward. */ private Physics mPhysics; diff --git a/src/teilchen/examples/SketchLesson02_Particles.java b/src/teilchen/examples/SketchLesson02_Particles.java index 9cc0974..9cd2b2c 100755 --- a/src/teilchen/examples/SketchLesson02_Particles.java +++ b/src/teilchen/examples/SketchLesson02_Particles.java @@ -8,8 +8,8 @@ public class SketchLesson02_Particles extends PApplet { /* - * this sketch shows how to create and handle multiple particles and remove - * individual particles. + * this sketch demonstrates how to create and handle multiple particles and remove individual + * particles. */ private Physics mPhysics; @@ -47,7 +47,7 @@ public void draw() { for (int i = 0; i < mPhysics.particles().size(); i++) { Particle mParticle = mPhysics.particles(i); if (mParticle.position().y > height * 0.9f) { - mPhysics.particles().remove(i); + mPhysics.particles().remove(i); // @TODO(check if this potentially creates an exception) } } diff --git a/src/teilchen/examples/SketchLesson03_Attractors.java b/src/teilchen/examples/SketchLesson03_Attractors.java index 1d02d6d..931ffde 100755 --- a/src/teilchen/examples/SketchLesson03_Attractors.java +++ b/src/teilchen/examples/SketchLesson03_Attractors.java @@ -10,7 +10,7 @@ public class SketchLesson03_Attractors extends PApplet { /* - * this sketch shows how to create and use attractors. + * this sketch demonstrates how to create and use an `Attractor` and how to teleport particles. */ private Physics mPhysics; diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson05_Spring.java b/src/teilchen/examples/SketchLesson04_Spring.java similarity index 81% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson05_Spring.java rename to src/teilchen/examples/SketchLesson04_Spring.java index 9449630..b096c68 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson05_Spring.java +++ b/src/teilchen/examples/SketchLesson04_Spring.java @@ -6,11 +6,11 @@ import teilchen.force.Spring; import teilchen.force.ViscousDrag; -public class SketchLesson05_Spring extends PApplet { +public class SketchLesson04_Spring extends PApplet { /* - * this sketch shows 1 how to create a viscous drag to slow motion eventually - * down. 2 how to create a spring that connects two particles. + * this sketch demonstrates how to create a `Spring` that connects two particles. it also + * demonstrates how to create a `ViscousDrag` to slow down particle motion over time. */ private Physics mPhysics; @@ -30,10 +30,10 @@ public void setup() { /* create two particles that we can connect with a spring */ Particle myA = mPhysics.makeParticle(); - myA.position().set(width / 2 - 50, height / 2); + myA.position().set(width / 2 - 50, height / 2.0f); Particle myB = mPhysics.makeParticle(); - myB.position().set(width / 2 + 50, height / 2); + myB.position().set(width / 2 + 50, height / 2.0f); /* create a spring force that connects two particles. * note that there is more than one way to create a spring. @@ -66,6 +66,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson05_Spring.class.getName()}); + PApplet.main(new String[]{SketchLesson04_Spring.class.getName()}); } } diff --git a/src/teilchen/examples/SketchLesson06_Springs.java b/src/teilchen/examples/SketchLesson05_Springs.java similarity index 86% rename from src/teilchen/examples/SketchLesson06_Springs.java rename to src/teilchen/examples/SketchLesson05_Springs.java index 8128faf..4d0c0da 100755 --- a/src/teilchen/examples/SketchLesson06_Springs.java +++ b/src/teilchen/examples/SketchLesson05_Springs.java @@ -5,11 +5,10 @@ import teilchen.Physics; import teilchen.force.Spring; -public class SketchLesson06_Springs extends PApplet { +public class SketchLesson05_Springs extends PApplet { /* - * this sketch shows 1 how to create a viscous drag to slow motion eventually - * down. 2 how to create a spring that connects two particles. + * this sketch demonstrates how to connect multiple particles with springs. */ private Physics mPhysics; @@ -24,7 +23,7 @@ public void setup() { mPhysics = new Physics(); /* create a particle to which we will connect springs */ - mRoot = mPhysics.makeParticle(width / 2, height / 2, 0.0f); + mRoot = mPhysics.makeParticle(width / 2.0f, height / 2.0f, 0.0f); /* we give the root particle a higher mass so it doesn t move as easily */ mRoot.mass(30); } @@ -69,7 +68,7 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson06_Springs.class.getName()}); + PApplet.main(new String[]{SketchLesson05_Springs.class.getName()}); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson07_StableQuads.java b/src/teilchen/examples/SketchLesson06_StableQuads.java similarity index 89% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson07_StableQuads.java rename to src/teilchen/examples/SketchLesson06_StableQuads.java index d75f582..7cedc20 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson07_StableQuads.java +++ b/src/teilchen/examples/SketchLesson06_StableQuads.java @@ -10,7 +10,12 @@ import teilchen.util.DrawLib; import teilchen.util.StableSpringQuad; -public class SketchLesson07_StableQuads extends PApplet { +public class SketchLesson06_StableQuads extends PApplet { + + /* + * this sketch demonstrates how to connect four particles and six springs to form a + * `StableSpringQuad` a construct that allows to emulate something similar to a *body*. + */ private Physics mPhysics; private Particle mRoot; @@ -83,6 +88,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson07_StableQuads.class.getName()}); + PApplet.main(new String[]{SketchLesson06_StableQuads.class.getName()}); } } diff --git a/src/teilchen/examples/SketchLesson08_Sticks.java b/src/teilchen/examples/SketchLesson07_Sticks.java similarity index 87% rename from src/teilchen/examples/SketchLesson08_Sticks.java rename to src/teilchen/examples/SketchLesson07_Sticks.java index 5f34b73..70482b7 100755 --- a/src/teilchen/examples/SketchLesson08_Sticks.java +++ b/src/teilchen/examples/SketchLesson07_Sticks.java @@ -7,7 +7,13 @@ import teilchen.force.Gravity; import teilchen.integration.Verlet; -public class SketchLesson08_Sticks extends PApplet { +public class SketchLesson07_Sticks extends PApplet { + + /* + * this sketch demonstrates how to use a stick to connect two particles. `Stick` is similar to + * `Spring` except that it does not use forces to move particles which results in a more + * *stiff* behavior. + */ private Physics mPhysics; private Particle[] mParticles; @@ -73,6 +79,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson08_Sticks.class.getName()}); + PApplet.main(new String[]{SketchLesson07_Sticks.class.getName()}); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson09_Cloth.java b/src/teilchen/examples/SketchLesson08_Cloth.java similarity index 92% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson09_Cloth.java rename to src/teilchen/examples/SketchLesson08_Cloth.java index 6fc662c..e064a96 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson09_Cloth.java +++ b/src/teilchen/examples/SketchLesson08_Cloth.java @@ -10,12 +10,15 @@ import teilchen.force.Gravity; import teilchen.integration.Verlet; -public class SketchLesson09_Cloth extends PApplet { +public class SketchLesson08_Cloth extends PApplet { + + /* + * this sketch demonstrate how to use particles and springs to emulate a piece of cloth. + */ private static final int GRID_WIDTH = 32; private static final int GRID_HEIGHT = 16; private Physics mPhysics; - private Particle[][] mParticles; private Attractor mAttractor; public void settings() { @@ -38,7 +41,7 @@ public void setup() { mAttractor.radius(300); mPhysics.add(mAttractor); - mParticles = new Particle[GRID_WIDTH][GRID_HEIGHT]; + Particle[][] mParticles = new Particle[GRID_WIDTH][GRID_HEIGHT]; /* setup cloth */ float mGridStepX = ((float) width / GRID_WIDTH); @@ -110,6 +113,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson09_Cloth.class.getName()}); + PApplet.main(new String[]{SketchLesson08_Cloth.class.getName()}); } } diff --git a/src/teilchen/examples/SketchLesson04_LineDeflector.java b/src/teilchen/examples/SketchLesson09_LineDeflector.java similarity index 86% rename from src/teilchen/examples/SketchLesson04_LineDeflector.java rename to src/teilchen/examples/SketchLesson09_LineDeflector.java index a0188f6..fbe1b6b 100755 --- a/src/teilchen/examples/SketchLesson04_LineDeflector.java +++ b/src/teilchen/examples/SketchLesson09_LineDeflector.java @@ -8,10 +8,11 @@ import teilchen.force.LineDeflector2D; import teilchen.force.ViscousDrag; -public class SketchLesson04_LineDeflector extends PApplet { +public class SketchLesson09_LineDeflector extends PApplet { /* - * this sketch shows 1 how to create and use line deflectors 2 how to use 'ShortLivedParticle' + * this sketch demonstrates how to create and use `LineDeflector2D` and how to use + * `ShortLivedParticle` a particle that only exists for a defined period of time. */ private Physics mPhysics; @@ -26,8 +27,8 @@ public void setup() { mPhysics = new Physics(); mDeflector = new LineDeflector2D(); - mDeflector.a().set(50, height / 2); - mDeflector.b().set(width - 50, height / 2 - 100); + mDeflector.a().set(50, height / 2.0f); + mDeflector.b().set(width - 50, height / 2.0f - 100); mPhysics.add(mDeflector); /* create gravity */ @@ -87,6 +88,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(SketchLesson04_LineDeflector.class.getName()); + PApplet.main(SketchLesson09_LineDeflector.class.getName()); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson04_PlaneDeflector.java b/src/teilchen/examples/SketchLesson10_PlaneDeflector.java similarity index 91% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson04_PlaneDeflector.java rename to src/teilchen/examples/SketchLesson10_PlaneDeflector.java index 5ebb4da..ce9e26b 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson04_PlaneDeflector.java +++ b/src/teilchen/examples/SketchLesson10_PlaneDeflector.java @@ -8,11 +8,11 @@ import teilchen.force.PlaneDeflector; import teilchen.force.ViscousDrag; -public class SketchLesson04_PlaneDeflector extends PApplet { +public class SketchLesson10_PlaneDeflector extends PApplet { /* - * this sketch shows 1 how to create and use plane deflectors 2 how to use - * 'ShortLivedParticle' + * this sketch demonstrates how to create and use ``PlaneDeflector` and how to use + * `ShortLivedParticle` a particle that only exists for a defined period of time. */ private Physics mPhysics; @@ -35,7 +35,7 @@ public void setup() { */ mDeflector = new PlaneDeflector(); /* set plane origin into the center of the screen */ - mDeflector.plane().origin.set(width / 2, height / 2, 0); + mDeflector.plane().origin.set(width / 2.0f, height / 2.0f, 0); mDeflector.plane().normal.set(0, -1, 0); /* the coefficient of restitution defines how hard particles bounce of the deflector */ mDeflector.coefficientofrestitution(0.7f); @@ -108,6 +108,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson04_PlaneDeflector.class.getName()}); + PApplet.main(new String[]{SketchLesson10_PlaneDeflector.class.getName()}); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson10_WanderBehavior.java b/src/teilchen/examples/SketchLesson11_WanderBehavior.java similarity index 83% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson10_WanderBehavior.java rename to src/teilchen/examples/SketchLesson11_WanderBehavior.java index 2f6a481..cd40d0f 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson10_WanderBehavior.java +++ b/src/teilchen/examples/SketchLesson11_WanderBehavior.java @@ -7,10 +7,11 @@ import teilchen.behavior.Wander; import teilchen.force.ViscousDrag; -public class SketchLesson10_WanderBehavior extends PApplet { +public class SketchLesson11_WanderBehavior extends PApplet { /* - * this sketch shows how to assign an 'wander' behavior to a particle. + * this sketch demonstrates how to use behaviors. it combines `Wander` and `Motor` behaviors + * to turn a `BehaviorParticle` into an autonomously moving *agent*. */ private Physics mPhysics; @@ -31,7 +32,7 @@ public void setup() { /* create particles */ mParticle = mPhysics.makeParticle(BehaviorParticle.class); - mParticle.position().set(width / 2, height / 2); + mParticle.position().set(width / 2.0f, height / 2.0f); mParticle.maximumInnerForce(100); mParticle.radius(10); @@ -67,6 +68,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson10_WanderBehavior.class.getName()}); + PApplet.main(new String[]{SketchLesson11_WanderBehavior.class.getName()}); } } diff --git a/processing-library/teilchen/src/teilchen/examples/SketchLesson11_ArrivalBehavior.java b/src/teilchen/examples/SketchLesson12_ArrivalBehavior.java similarity index 88% rename from processing-library/teilchen/src/teilchen/examples/SketchLesson11_ArrivalBehavior.java rename to src/teilchen/examples/SketchLesson12_ArrivalBehavior.java index 4e11fc0..eff4e46 100755 --- a/processing-library/teilchen/src/teilchen/examples/SketchLesson11_ArrivalBehavior.java +++ b/src/teilchen/examples/SketchLesson12_ArrivalBehavior.java @@ -5,10 +5,11 @@ import teilchen.Physics; import teilchen.behavior.Arrival; -public class SketchLesson11_ArrivalBehavior extends PApplet { +public class SketchLesson12_ArrivalBehavior extends PApplet { /* - * this sketch shows how to assign an 'arrival' behavior to a particle. + * this sketch demonstrates how to use behaviors. it appliies the `Arrival` behavior to make a + * `BehaviorParticle` arrive at a certain location. */ private Physics mPhysics; @@ -75,6 +76,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[]{SketchLesson11_ArrivalBehavior.class.getName()}); + PApplet.main(new String[]{SketchLesson12_ArrivalBehavior.class.getName()}); } } diff --git a/src/teilchen/examples/SketchLessonX01_Overlap.java b/src/teilchen/examples/SketchLessonX01_Overlap.java index c453812..e46c3da 100755 --- a/src/teilchen/examples/SketchLessonX01_Overlap.java +++ b/src/teilchen/examples/SketchLessonX01_Overlap.java @@ -12,8 +12,8 @@ public class SketchLessonX01_Overlap extends PApplet { /* - * this sketch is exactly like Lesson06_Springs, except that it also shows how - * to resolveOverlap overlaps. + * this sketch is exactly like `Lesson06_Springs` except that it also shows how to resolve + * overlaps of particles by moving particles apart manipulating their position directly. */ private static final float PARTICLE_RADIUS = 13; @@ -31,7 +31,7 @@ public void setup() { mPhysics.add(new ViscousDrag()); mPhysics.add(new Gravity(new PVector(0, 100f, 0))); - mRoot = mPhysics.makeParticle(width / 2, height / 2, 0.0f); + mRoot = mPhysics.makeParticle(width / 2.0f, height / 2.0f, 0.0f); mRoot.mass(30); mRoot.fixed(true); mRoot.radius(PARTICLE_RADIUS); @@ -52,7 +52,7 @@ public void draw() { /* move overlapping particles away from each other */ for (int i = 0; i < 10; i++) { - mRoot.position().set(width / 2, height / 2, 0.0f); // a bit of a 'hack' + mRoot.position().set(width / 2.0f, height / 2.0f, 0.0f); // a bit of a 'hack' Overlap.resolveOverlap(mPhysics.particles()); } diff --git a/src/teilchen/examples/SketchLessonX02_Collisions.java b/src/teilchen/examples/SketchLessonX02_Collisions.java index d7fe5e5..31f07fd 100755 --- a/src/teilchen/examples/SketchLessonX02_Collisions.java +++ b/src/teilchen/examples/SketchLessonX02_Collisions.java @@ -12,6 +12,11 @@ public class SketchLessonX02_Collisions extends PApplet { + /* + * this sketch demonstrates how to use `CollisionManager` to resolve particle collisions by + * applying temporary springs pushing 2 colliding particles appart. + */ + private static final float PARTICLE_SIZE = 12; private CollisionManager mCollision; private Physics mPhysics; diff --git a/src/teilchen/examples/SketchLessonX03_ParticlesLeavingTrails.java b/src/teilchen/examples/SketchLessonX03_ParticlesLeavingTrails.java index c88e7cd..5727568 100755 --- a/src/teilchen/examples/SketchLessonX03_ParticlesLeavingTrails.java +++ b/src/teilchen/examples/SketchLessonX03_ParticlesLeavingTrails.java @@ -15,6 +15,10 @@ public class SketchLessonX03_ParticlesLeavingTrails extends PApplet { + /* + * this sketch demonstrates how to use `ParticleTrail` to make particles leave a trail. + */ + private Physics mPhysics; private ArrayList mTrails; private Attractor mAttractor; @@ -61,15 +65,7 @@ public void setup() { myParticleTrail.mass(0.5f); mTrails.add(myParticleTrail); } - resetParticles(width / 2, height / 2); - } - - private void resetParticles(float x, float y) { - for (ParticleTrail myTrails : mTrails) { - myTrails.particle().position().set(x + random(-10, 10), y + random(-10, 10), 0); - myTrails.particle().velocity().set(random(-10, 10), random(-10, 10), random(-10, 10)); - myTrails.fragments().clear(); - } + resetParticles(width / 2.0f, height / 2.0f); } public void draw() { @@ -88,6 +84,18 @@ public void draw() { } } + public void mousePressed() { + resetParticles(mouseX, mouseY); + } + + private void resetParticles(float x, float y) { + for (ParticleTrail myTrails : mTrails) { + myTrails.particle().position().set(x + random(-10, 10), y + random(-10, 10), 0); + myTrails.particle().velocity().set(random(-10, 10), random(-10, 10), random(-10, 10)); + myTrails.fragments().clear(); + } + } + private void drawTrail(ParticleTrail theTrail) { final ArrayList mFragments = theTrail.fragments(); @@ -129,10 +137,6 @@ private void drawTrail(ParticleTrail theTrail) { } } - public void mousePressed() { - resetParticles(mouseX, mouseY); - } - public static void main(String[] args) { PApplet.main(new String[]{SketchLessonX03_ParticlesLeavingTrails.class.getName()}); } diff --git a/src/teilchen/examples/SketchLessonX04_StickMan.java b/src/teilchen/examples/SketchLessonX04_StickMan.java index a09d41e..e6bad26 100755 --- a/src/teilchen/examples/SketchLessonX04_StickMan.java +++ b/src/teilchen/examples/SketchLessonX04_StickMan.java @@ -13,14 +13,13 @@ public class SketchLessonX04_StickMan extends PApplet { /* - * this demo shows some advanced use of particles, springs and attractors to - * create stickmen. + * this sketch demonstratwa some advanced use of particles, springs ( e.g `MuscleSpring` ) + * and attractors to create a group of `StickMan`. */ private Physics mPhysics; private Attractor mAttractor; private Gravity mGravity; - private ViscousDrag mViscousDrag; private StickMan[] mMyStickMan; public void settings() { @@ -38,14 +37,14 @@ public void setup() { mGravity.force().y = 20; mPhysics.add(mGravity); - mViscousDrag = new ViscousDrag(); + ViscousDrag mViscousDrag = new ViscousDrag(); mViscousDrag.coefficient = 0.85f; mPhysics.add(mViscousDrag); mAttractor = new Attractor(); mAttractor.radius(500); mAttractor.strength(0); - mAttractor.position().set(width / 2, height / 2); + mAttractor.position().set(width / 2.0f, height / 2.0f); mPhysics.add(mAttractor); mMyStickMan = new StickMan[20]; diff --git a/src/teilchen/examples/SketchLessonX05_AngleConstraints.java b/src/teilchen/examples/SketchLessonX05_AngleConstraints.java index 787e3a5..3bb41c7 100755 --- a/src/teilchen/examples/SketchLessonX05_AngleConstraints.java +++ b/src/teilchen/examples/SketchLessonX05_AngleConstraints.java @@ -13,6 +13,10 @@ public class SketchLessonX05_AngleConstraints extends PApplet { + /* + * this sketch demonstrates how to contraint the angle between two springs or two sticks. + */ + private Physics mPhysics; private Particle mParticleA; private Particle mParticleB; @@ -43,10 +47,10 @@ public void setup() { mParticleC = mPhysics.makeParticle(); mParticleD = mPhysics.makeParticle(); - mParticleA.position().set(width / 2 + 50, height / 3); - mParticleB.position().set(width / 2, height - height / 1.75f); - mParticleC.position().set(width / 2, height - height / 4); - mParticleD.position().set(width / 2, height - height / 8); + mParticleA.position().set(width / 2.0f + 50, height / 3.0f); + mParticleB.position().set(width / 2.0f, height - height / 1.75f); + mParticleC.position().set(width / 2.0f, height - height / 4.0f); + mParticleD.position().set(width / 2.0f, height - height / 8.0f); mParticleA.radius(7); mParticleB.radius(3); diff --git a/src/teilchen/examples/SketchLessonX06_Ducklings.java b/src/teilchen/examples/SketchLessonX06_Ducklings.java index 90651c5..325110c 100755 --- a/src/teilchen/examples/SketchLessonX06_Ducklings.java +++ b/src/teilchen/examples/SketchLessonX06_Ducklings.java @@ -13,8 +13,8 @@ public class SketchLessonX06_Ducklings extends PApplet { /* - * this demo shows how to add behaviors to particles. in this example the - * arrival behavior. + * this sketch demonstrates how to use `Arrival` behaviors with particles to create a group of + * ducklings. */ private Physics mPhysics; @@ -26,7 +26,6 @@ public void settings() { } public void setup() { - frameRate(60); colorMode(RGB, 1.0f); /* physics */ diff --git a/src/teilchen/examples/SketchLessonX07_CubicleWorld.java b/src/teilchen/examples/SketchLessonX07_CubicleWorld.java index 948fb24..94e9ba3 100755 --- a/src/teilchen/examples/SketchLessonX07_CubicleWorld.java +++ b/src/teilchen/examples/SketchLessonX07_CubicleWorld.java @@ -12,14 +12,20 @@ public class SketchLessonX07_CubicleWorld extends PApplet { + /* + * this sketch demonstrates how to use `CubicleWorld` to separate a given space into equally + * sized cubes in order to only draw paticles from a specific cube. this mechanism is helpful + * to avoid decrease the in demand for computational resources in particle systems with large + * numbers of particles. + */ + private final int WORLD_NUMBER_OF_CUBICLES = 15; private final float WORLD_CUBICLE_SCALE = 20; private final float WORLD_SCALE = WORLD_NUMBER_OF_CUBICLES * WORLD_CUBICLE_SCALE; - private final boolean showCubicles = true; + private final boolean mShowCubicles = true; private final PVector mPosition = new PVector(); private float mRotationZ = 0.1f; private CubicleWorld mCubicleWorld; - private CubicleWorldView mCubicleWorldView; public void settings() { @@ -38,16 +44,14 @@ public void setup() { mCubicleWorldView = new CubicleWorldView(mCubicleWorld); mCubicleWorldView.color_empty = color(0, 1); - mCubicleWorldView.color_full = color(0, 4); + mCubicleWorldView.color_full = color(0, 2); mCubicleWorld.add(new MCubicleEntity()); } public void draw() { - /* handle entities */ - if (frameRate > 30) { - addRandomEntities(2); - } + /* add entities */ + addRandomEntities(10); mCubicleWorld.update(); ArrayList mEntities = mCubicleWorld.getLocalEntities(mPosition, 1); @@ -56,22 +60,21 @@ public void draw() { background(255); pushMatrix(); - translate(width / 2, height / 2, 0); + translate(width / 2.0f, height / 2.0f, 0); /* rotate */ if (mousePressed) { mRotationZ += (mouseX * 0.01f - mRotationZ) * 0.05f; } else { - mPosition.x = mouseX - width / 2; - mPosition.y = mouseY - height / 2; + mPosition.x = mouseX - width / 2.0f; + mPosition.y = mouseY - height / 2.0f; } rotateX(THIRD_PI); rotateZ(mRotationZ); /* draw cubicle world */ - if (showCubicles) { - strokeWeight(0.1f); - stroke(0, 127); + if (mShowCubicles) { + strokeWeight(1.0f / mCubicleWorld.cellscale().x); // unscale stroke weight noFill(); mCubicleWorldView.draw(g); } diff --git a/src/teilchen/examples/SketchLessonX08_Schwarm.java b/src/teilchen/examples/SketchLessonX08_Schwarm.java index 35a0df1..aa65021 100755 --- a/src/teilchen/examples/SketchLessonX08_Schwarm.java +++ b/src/teilchen/examples/SketchLessonX08_Schwarm.java @@ -18,6 +18,11 @@ public class SketchLessonX08_Schwarm extends PApplet { + /* + * this sketch demonstrates how to create a complex swarm behavior by combining the four simple + * behaviors `Separation`, `Alignment`, `Cohesion` and `Wander` ( plus `Motor` ). + */ + private Physics mPhysics; private ArrayList mSwarmEntities; @@ -73,13 +78,9 @@ public void draw() { private class SwarmEntity extends BehaviorParticle { private final Separation separation; - private final Alignment alignment; - private final Cohesion cohesion; - private final Wander wander; - private final Motor motor; public SwarmEntity() { diff --git a/src/teilchen/examples/SketchLessonX09_TriangleDeflector.java b/src/teilchen/examples/SketchLessonX09_TriangleDeflector.java index 526380d..6b458b1 100755 --- a/src/teilchen/examples/SketchLessonX09_TriangleDeflector.java +++ b/src/teilchen/examples/SketchLessonX09_TriangleDeflector.java @@ -2,6 +2,7 @@ import processing.core.PApplet; import processing.core.PVector; +import teilchen.MortalParticle; import teilchen.Particle; import teilchen.Physics; import teilchen.force.Gravity; @@ -12,6 +13,12 @@ public class SketchLessonX09_TriangleDeflector extends PApplet { + /* + * this sketch demonstrates how to use `TriangleDeflectors` to make particles bounce off two + * triangles. it also demonstrates how to use `MortalParticle` to remove particles + * automatically once they leave the screen. + */ + private Physics mPhysics; private ArrayList mTriangleDeflectors; @@ -31,9 +38,7 @@ public void setup() { /* triangle deflectors */ final PVector[] mVertices = new PVector[]{new PVector(0, 0, 0), new PVector(width, height, 0), - new PVector(0, - height, - 0), + new PVector(0, height, 0), new PVector(0, 0, 0), new PVector(width, 0, 0), new PVector(width, height, 0),}; @@ -44,26 +49,19 @@ public void setup() { public void draw() { if (mousePressed) { /* create and add a particle to the system */ - Particle mParticle = mPhysics.makeParticle(); + MyMortalParticle mParticle = new MyMortalParticle(); + mPhysics.add(mParticle); /* set particle to mouse position with random velocity */ - mParticle.position().set(mouseX, random(height), height / 2); + mParticle.position().set(mouseX, random(height), height / 2.0f); mParticle.velocity().set(random(-20, 20), 0, random(20)); } final float mDeltaTime = 1.0f / frameRate; mPhysics.step(mDeltaTime); - /* remove particles */ - for (int i = 0; i < mPhysics.particles().size(); i++) { - Particle mParticle = mPhysics.particles(i); - if (mParticle.position().z < -height) { - mPhysics.particles().remove(i); - } - } - /* draw particles */ background(255); - camera(width / 2, mouseY + height, height * 1.3f - mouseY, width / 2, height / 2, 0, 0, 1, 0); + camera(width / 2.0f, mouseY + height, height * 1.3f - mouseY, width / 2.0f, height / 2.0f, 0, 0, 1, 0); noStroke(); sphereDetail(10); @@ -90,6 +88,13 @@ public void draw() { mPhysics.removeTags(); } + private class MyMortalParticle extends MortalParticle { + + public boolean isDead() { + return position().z < -height; + } + } + public static void main(String[] args) { PApplet.main(new String[]{SketchLessonX09_TriangleDeflector.class.getName()}); } diff --git a/src/teilchen/examples/SketchLessonX10_TriangleDeflector2D.java b/src/teilchen/examples/SketchLessonX10_TriangleDeflector2D.java index bc00b9a..0a26a8c 100755 --- a/src/teilchen/examples/SketchLessonX10_TriangleDeflector2D.java +++ b/src/teilchen/examples/SketchLessonX10_TriangleDeflector2D.java @@ -1,6 +1,7 @@ package teilchen.examples; import processing.core.PApplet; +import teilchen.MortalParticle; import teilchen.Particle; import teilchen.Physics; import teilchen.force.Gravity; @@ -8,6 +9,12 @@ public class SketchLessonX10_TriangleDeflector2D extends PApplet { + /* + * this sketch demonstrates how to use `TriangleDeflectors` in a 2D context to make particles + * bounce off a triangle ( that looks like a line ). it also demonstrates how to use + * `MortalParticle` to remove particles automatically once they leave the screen. + */ + private Physics mPhysics; private TriangleDeflector mTriangleDeflector; @@ -35,14 +42,6 @@ public void draw() { final float mDeltaTime = 1.0f / frameRate; mPhysics.step(mDeltaTime); - /* remove particles */ - for (int i = 0; i < mPhysics.particles().size(); i++) { - Particle mParticle = mPhysics.particles(i); - if (mParticle.position().y > height || mParticle.still()) { - mPhysics.particles().remove(i); //@TODO(this might cause an exception. should be replaced by iterator) - } - } - /* draw particles */ background(255); @@ -67,14 +66,22 @@ public void draw() { /* finally remove the collision tag */ mPhysics.removeTags(); + + if (mousePressed) { + /* create and add a particle to the system */ + MyMortalParticle mParticle = new MyMortalParticle(); + mPhysics.add(mParticle); + /* set particle to mouse position with random velocity */ + mParticle.position().set(mouseX, mouseY); + mParticle.velocity().set(random(-20, 20), 0); + } } - public void mousePressed() { - /* create and add a particle to the system */ - Particle mParticle = mPhysics.makeParticle(); - /* set particle to mouse position with random velocity */ - mParticle.position().set(mouseX, mouseY); - mParticle.velocity().set(random(-20, 20), 0); + private class MyMortalParticle extends MortalParticle { + + public boolean isDead() { + return position().y > height || still(); + } } public static void main(String[] args) { diff --git a/src/teilchen/examples/SketchLessonX12_Pendulum.java b/src/teilchen/examples/SketchLessonX11_Pendulum.java similarity index 83% rename from src/teilchen/examples/SketchLessonX12_Pendulum.java rename to src/teilchen/examples/SketchLessonX11_Pendulum.java index 02d480d..aaffed5 100644 --- a/src/teilchen/examples/SketchLessonX12_Pendulum.java +++ b/src/teilchen/examples/SketchLessonX11_Pendulum.java @@ -6,12 +6,15 @@ import teilchen.force.Gravity; import teilchen.force.Pulse; import teilchen.force.Spring; -import teilchen.integration.Verlet; -public class SketchLessonX12_Pendulum extends PApplet { +public class SketchLessonX11_Pendulum extends PApplet { - private Physics mPhysics; + /* + * this sketch demonstrates how to create a pendulum from two particles, a spring and a pulse + * force. + */ + private Physics mPhysics; private Particle mPendulumRoot; private Particle mPendulumTip; private Pulse mPulse; @@ -27,12 +30,12 @@ public void setup() { mPhysics.add(mGravity); mPendulumRoot = mPhysics.makeParticle(0, 0, 0, 0.05f); - mPendulumRoot.position().set(width / 2, 100); + mPendulumRoot.position().set(width / 2.0f, 100); mPendulumRoot.fixed(true); mPendulumTip = mPhysics.makeParticle(0, 0, 0, 0.05f); - float mSegmentLength = height / 2; + float mSegmentLength = height / 2.0f; Spring mConnection = new Spring(mPendulumRoot, mPendulumTip, mSegmentLength); mConnection.damping(0.0f); mConnection.strength(10); @@ -68,6 +71,6 @@ public void mousePressed() { } public static void main(String[] args) { - PApplet.main(SketchLessonX12_Pendulum.class.getName()); + PApplet.main(SketchLessonX11_Pendulum.class.getName()); } } diff --git a/src/teilchen/force/MuscleSpring.java b/src/teilchen/force/MuscleSpring.java index 3867af2..f7e71b8 100755 --- a/src/teilchen/force/MuscleSpring.java +++ b/src/teilchen/force/MuscleSpring.java @@ -66,8 +66,8 @@ public float restlength() { return mInitialRestLength; } - public void restlength(float theRestLength) { - mInitialRestLength = theRestLength; + public void restlength(float pRestLength) { + mInitialRestLength = pRestLength; } public void frequency(final float theFrequency) { diff --git a/src/teilchen/force/Spring.java b/src/teilchen/force/Spring.java index 533d9d9..7a33f39 100755 --- a/src/teilchen/force/Spring.java +++ b/src/teilchen/force/Spring.java @@ -31,43 +31,37 @@ public class Spring implements IForce, IConnection { protected float mSpringConstant; - protected float mSpringDamping; - protected float mRestLength; - protected Particle mA; - protected Particle mB; - protected boolean mOneWay; - protected boolean mActive; - public Spring(Particle theA, Particle theB) { - this(theA, theB, 2.0f, 0.1f, distance(theA.position(), theB.position())); + public Spring(Particle pA, Particle pB) { + this(pA, pB, 2.0f, 0.1f, distance(pA.position(), pB.position())); } - public Spring(final Particle theA, - final Particle theB, - final float theSpringConstant, - final float theSpringDamping, - final float theRestLength) { - mSpringConstant = theSpringConstant; - mSpringDamping = theSpringDamping; - mRestLength = theRestLength; - mA = theA; - mB = theB; + public Spring(final Particle pA, + final Particle pB, + final float pSpringConstant, + final float pSpringDamping, + final float pRestLength) { + mSpringConstant = pSpringConstant; + mSpringDamping = pSpringDamping; + mRestLength = pRestLength; + mA = pA; + mB = pB; mOneWay = false; mActive = true; } - public Spring(Particle theA, Particle theB, float theRestLength) { - this(theA, theB, 2.0f, 0.1f, theRestLength); + public Spring(Particle pA, Particle pB, float pRestLength) { + this(pA, pB, 2.0f, 0.1f, pRestLength); } - public Spring(Particle theA, Particle theB, final float theSpringConstant, final float theSpringDamping) { - this(theA, theB, theSpringConstant, theSpringDamping, distance(theA.position(), theB.position())); + public Spring(Particle pA, Particle pB, final float pSpringConstant, final float pSpringDamping) { + this(pA, pB, pSpringConstant, pSpringDamping, distance(pA.position(), pB.position())); } public void setRestLengthByPosition() { @@ -78,8 +72,8 @@ public float restlength() { return mRestLength; } - public void restlength(float theRestLength) { - mRestLength = theRestLength; + public void restlength(float pRestLength) { + mRestLength = pRestLength; } public final Particle a() { @@ -90,46 +84,36 @@ public final Particle b() { return mB; } - public final Particle a(Particle theA) { - return mA = theA; + public final Particle a(Particle pA) { + return mA = pA; } - public final Particle b(Particle theB) { - return mB = theB; + public final Particle b(Particle pB) { + return mB = pB; } public final float currentLength() { return distance(mA.position(), mB.position()); } - /** - spring constant. - - @return float - */ public final float strength() { return mSpringConstant; } - /** - spring constant. - - @param theSpringConstant float - */ - public final void strength(float theSpringConstant) { - mSpringConstant = theSpringConstant; + public final void strength(float pSpringConstant) { + mSpringConstant = pSpringConstant; } public final float damping() { return mSpringDamping; } - public final void damping(float theSpringDamping) { - mSpringDamping = theSpringDamping; + public final void damping(float pSpringDamping) { + mSpringDamping = pSpringDamping; } - public void setOneWay(boolean theOneWayState) { - mOneWay = theOneWayState; + public void setOneWay(boolean pOneWayState) { + mOneWay = pOneWayState; } public void apply(final float pDeltaTime, final Physics pParticleSystem) { @@ -175,14 +159,6 @@ public void apply(final float pDeltaTime, final Physics pParticleSystem) { // } } - protected static float fastInverseSqrt(float v) { - final float half = 0.5f * v; - int i = Float.floatToIntBits(v); - i = 0x5f375a86 - (i >> 1); - v = Float.intBitsToFloat(i); - return v * (1.5f - half * v * v); - } - public boolean dead() { return mA.dead() || mB.dead(); } @@ -194,4 +170,12 @@ public boolean active() { public void active(boolean pActiveState) { mActive = pActiveState; } + + protected static float fastInverseSqrt(float v) { + final float half = 0.5f * v; + int i = Float.floatToIntBits(v); + i = 0x5f375a86 - (i >> 1); + v = Float.intBitsToFloat(i); + return v * (1.5f - half * v * v); + } } diff --git a/src/teilchen/test/TestIntersectRayTriangle.java b/src/teilchen/test/TestIntersectRayTriangle.java index 81147f7..b14ade4 100755 --- a/src/teilchen/test/TestIntersectRayTriangle.java +++ b/src/teilchen/test/TestIntersectRayTriangle.java @@ -22,7 +22,7 @@ public void setup() { public void draw() { background(50); - translate(width / 2, height / 2); + translate(width / 2.0f, height / 2.0f); if (!mousePressed) { mRotationX = TWO_PI * mouseY / (float) height; mRotationY = TWO_PI * mouseX / (float) width; @@ -33,8 +33,8 @@ public void draw() { PVector rayOrigin = new PVector(0, 0, 0); PVector rayVector = new PVector(mRayX, mRayY, -100); if (mousePressed) { - mRayX = mouseX - width / 2; - mRayY = mouseY - height / 2; + mRayX = mouseX - width / 2.0f; + mRayY = mouseY - height / 2.0f; } PVector v0 = new PVector(-100, -100, -200); PVector v1 = new PVector(100, -100, -200); diff --git a/src/teilchen/util/CollisionManager.java b/src/teilchen/util/CollisionManager.java index 2e91ff3..057b956 100755 --- a/src/teilchen/util/CollisionManager.java +++ b/src/teilchen/util/CollisionManager.java @@ -19,19 +19,22 @@ * {@link http://www.gnu.org/licenses/lgpl.html} * */ + package teilchen.util; -import java.util.ArrayList; import processing.core.PVector; import teilchen.Particle; import teilchen.Physics; -import static teilchen.Physics.EPSILON; import teilchen.constraint.Stick; import teilchen.cubicle.CubicleParticle; import teilchen.cubicle.CubicleWorld; import teilchen.cubicle.ICubicleEntity; import teilchen.force.IForce; import teilchen.force.Spring; + +import java.util.ArrayList; + +import static teilchen.Physics.EPSILON; import static teilchen.util.Util.distance; import static teilchen.util.Util.lengthSquared; @@ -42,38 +45,19 @@ */ public class CollisionManager { + public static final int DISTANCE_MODE_RADIUS = 0; + public static final int DISTANCE_MODE_FIXED = 1; public boolean HINT_IGNORE_STILL_OR_FIXED = false; - + private final Physics mCollisionPhysics; + private final Random mRandom; private float mCollisionSpringConstant; - private float mCollisionSpringDamping; - - private final Physics mCollisionPhysics; - private float mMinimumDistance; - - private PVector mResolveSamePosition; - - public enum ResolverType { -// COLLISION_STICK, COLLISION_SPRING, - - SPRING, STICK - - } - private final Random mRandom; - + private final PVector mResolveSamePosition; private ResolverType mResolverType; - private float mCollisionResolverIntervalCounter = 1; - private float mCollisionResolverInterval = 0; - private int mDistanceMode = DISTANCE_MODE_FIXED; - - public static final int DISTANCE_MODE_RADIUS = 0; - - public static final int DISTANCE_MODE_FIXED = 1; - public CollisionManager() { this(new Physics()); } @@ -178,6 +162,15 @@ public void createCollisionResolvers() { } } + public void createCollisionResolvers(final CubicleWorld theWorld) { + for (int i = 0; i < mCollisionPhysics.particles().size(); i++) { + final Particle myParticle = mCollisionPhysics.particles().get(i); + if (myParticle instanceof CubicleParticle) { + createCollisionResolver(theWorld, (CubicleParticle) myParticle); + } + } + } + private void createCollisionResolver(final Particle theParticle, final int theStart) { if (HINT_IGNORE_STILL_OR_FIXED) { if (theParticle.fixed() || theParticle.still()) { @@ -193,7 +186,7 @@ private void createCollisionResolver(final Particle theParticle, final int theSt if (theParticle.fixed() && myOtherParticle.fixed()) { // continue; } - /** + /* * because of the way we handle the collision resolver * creation there is no need to check for multiple spring * connections. @@ -228,15 +221,6 @@ private void createCollisionResolver(final Particle theParticle, final int theSt } } - public void createCollisionResolvers(final CubicleWorld theWorld) { - for (int i = 0; i < mCollisionPhysics.particles().size(); i++) { - final Particle myParticle = mCollisionPhysics.particles().get(i); - if (myParticle instanceof CubicleParticle) { - createCollisionResolver(theWorld, (CubicleParticle) myParticle); - } - } - } - private void createCollisionResolver(final CubicleWorld theWorld, final CubicleParticle theParticle) { if (HINT_IGNORE_STILL_OR_FIXED) { if (theParticle.fixed() || theParticle.still()) { @@ -305,6 +289,11 @@ private float getMinimumDistance(Particle theParticle, Particle myOtherParticle) return myMinimumDistance; } + public enum ResolverType { + // COLLISION_STICK, COLLISION_SPRING, + SPRING, STICK + } + public static class CollisionSpring extends Spring { diff --git a/src/teilchen/util/StickMan.java b/src/teilchen/util/StickMan.java index 8af6fae..e736d88 100755 --- a/src/teilchen/util/StickMan.java +++ b/src/teilchen/util/StickMan.java @@ -11,15 +11,10 @@ public class StickMan { private final StableSpringQuad _myQuad; - private final float _myScale; - private final BasicParticle myLeftFoot; - private final BasicParticle myRightFoot; - private final BasicParticle myLeftHand; - private final BasicParticle myRightHand; public StickMan(Physics theParticleSystem, float theOffset, float theScale) { diff --git a/src/teilchen/wip/Sketch_ExplodingZeldaShrine.java b/src/teilchen/wip/Sketch_ExplodingZeldaShrine.java index 6e7d20a..9062ed6 100755 --- a/src/teilchen/wip/Sketch_ExplodingZeldaShrine.java +++ b/src/teilchen/wip/Sketch_ExplodingZeldaShrine.java @@ -16,7 +16,7 @@ public void settings() { } public void setup() { - p1.set(width / 2, height / 2); + p1.set(width / 2.0f, height / 2.0f); } public void draw() { @@ -40,7 +40,7 @@ private void laser_line(PVector v1, PVector d = PVector.sub(v2, v1); PVector c = new PVector(-d.y, d.x); c.normalize(); - c.mult(pLineWidth / 2); + c.mult(pLineWidth / 2.0f); beginShape(QUADS); /* core */ fill(pColorCore); diff --git a/src/teilchen/examples/SketchLessonX11_NonIntersectingStructures.java b/src/teilchen/wip/Sketch_NonIntersectingStructures.java similarity index 93% rename from src/teilchen/examples/SketchLessonX11_NonIntersectingStructures.java rename to src/teilchen/wip/Sketch_NonIntersectingStructures.java index ee463fe..4ea56f1 100644 --- a/src/teilchen/examples/SketchLessonX11_NonIntersectingStructures.java +++ b/src/teilchen/wip/Sketch_NonIntersectingStructures.java @@ -1,4 +1,4 @@ -package teilchen.examples; +package teilchen.wip; import processing.core.PApplet; import teilchen.Particle; @@ -10,7 +10,7 @@ import java.util.ArrayList; -public class SketchLessonX11_NonIntersectingStructures extends PApplet { +public class Sketch_NonIntersectingStructures extends PApplet { // @TODO(not fully functional yet) @@ -86,6 +86,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(SketchLessonX11_NonIntersectingStructures.class.getName()); + PApplet.main(Sketch_NonIntersectingStructures.class.getName()); } } diff --git a/teilchen.txt b/teilchen.txt new file mode 100644 index 0000000..b5b7d7a --- /dev/null +++ b/teilchen.txt @@ -0,0 +1,12 @@ +name = teilchen +authors = [Dennis P Paul](https://dennisppaul.de/) +url = https://github.com/dennisppaul/teilchen +categories = Simulation +sentence = teilchen a simple physics library based on particles, forces, constraints and behaviors. +paragraph = it is also a collection of a variety of concepts useful for modeling with virtual physics and behaviors. nothing new, nothing fancy, except maybe for the combination of forces ( external forces ) and behavior ( internal forces ). it is also a [processing.org](http://processing.org "Processing.org")-style library. and teilchen is a german word and a synonym for Partikel which translates to the english particle. the library is hosted on github [teilchen](https://github.com/dennisppaul/teilchen). +version = 3 +prettyVersion = 0.3 +minRevision = 246 +maxRevision = 0 + +# direct download link: https://github.com/dennisppaul/teilchen/releases/latest/download/teilchen.zip diff --git a/teilchen.zip b/teilchen.zip index a22651d..02e6503 100644 Binary files a/teilchen.zip and b/teilchen.zip differ