moving the vector examples and adding comments

This commit is contained in:
shiffman
2012-07-17 19:08:14 +00:00
parent 87b57b9258
commit 4fcb6def6d
10 changed files with 23 additions and 8 deletions
@@ -9,7 +9,7 @@
PShape circle;
void setup() {
size(640, 360, P3D);
size(640, 360, P2D);
smooth();
// Creating the PShape as an ellipse
// The corner is -50,-50 so that the center is at 0,0
@@ -19,8 +19,9 @@ void setup() {
void draw() {
background(51);
// We can dynamically set the stroke and fill of the shape
circle.stroke(255); // Not working in P2D??
circle.fill(map(mouseX,0,width,0,255));
circle.stroke(255);
circle.strokeWeight(4);
circle.fill(map(mouseX,0,width,0,255)); // Not working in P2D??
// We can use translate to move the PShape
translate(mouseX, mouseY);
// Drawing the PShape
@@ -4,7 +4,7 @@
* How to load an SVG into a PShape
*/
// PShapoe object
// PShape object
PShape svg;
void setup() {
@@ -5,16 +5,21 @@
* Demonstration of multiple force acting on bodies (Mover class)
* Bodies experience gravity continuously
* Bodies experience fluid resistance when in "water"
*
* For the basics of working with PVector, see
* http://processing.org/learning/pvector/
* as well as examples in Topics/Vectors/
*
*/
// Five moving bodies
Mover[] movers = new Mover[5];
Mover[] movers = new Mover[10];
// Liquid
Liquid liquid;
void setup() {
size(360, 640);
size(640, 360);
smooth();
reset();
// Create liquid object
@@ -60,7 +65,7 @@ void mousePressed() {
// Restart all the Mover objects randomly
void reset() {
for (int i = 0; i < movers.length; i++) {
movers[i] = new Mover(random(1, 5), 40+i*70, 0);
movers[i] = new Mover(random(0.5, 3), 40+i*70, 0);
}
}
@@ -8,6 +8,11 @@
* m2 --> mass of object #2
* d ---> distance between objects
* F = (G*m1*m2)/(d*d)
*
* For the basics of working with PVector, see
* http://processing.org/learning/pvector/
* as well as examples in Topics/Vectors/
*
*/
// A bunch of planets
@@ -5,6 +5,9 @@
* Demonstration of the basics of motion with vector.
* A "Mover" object stores location, velocity, and acceleration as vectors
* The motion is controlled by affecting the acceleration (in this case towards the mouse)
*
* For more examples of simulating motion and physics with vectors, see
* Simulate/ForcesWithVectors, Simulate/GravitationalAttraction3D
*/
// A Mover object
@@ -3,7 +3,8 @@
* by Daniel Shiffman.
*
* Demonstration of using vectors to control motion of body
* This example is not object-oriented (see AccelerationWithVectors and ForcesWithVectors for OOP)
* This example is not object-oriented
* See AccelerationWithVectors for an example of how to simulate motion using vectors in an object
*/
PVector location; // Location of shape