We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › Do not divide to conquer
Page Index Toggle Pages: 1
Do not divide to conquer (Read 3592 times)
Do not divide to conquer
Jun 12th, 2005, 8:37pm
 
Hi,

I posted a topic "VectorD" not to long ago but I think it is better to make a new one.

Here is the idea.
I wrote a simple vector library for processing. When I posted it many people told me that their exist already such libraries. And it's true. Many programmers wrote their own library. Some focused on vector with n dimension other on data transport , and other fancy stuff.
The thing is that none of those is posted as official library on the processing site.

So what I propose is this.
Since vectors are important for a software like processing why not regroup all those libraries. Take the best of each one and make one big vector library for processing.

Tell me what you think about that.


Re: Do not divide to conquer
Reply #1 - Jun 13th, 2005, 2:34am
 
Yes, I think thats a good idea.
Re: Do not divide to conquer
Reply #2 - Jun 13th, 2005, 9:51am
 
Just uploaded the source code on http://wilma.vub.ac.be/~aarrassi
Re: Do not divide to conquer
Reply #3 - Jun 13th, 2005, 11:02am
 
Yeah, that's definitely a very important thing. But I'm not sure, if a simple vector class would justify a whole library. So those things you spoke about like a physics class should get into it as well. Very important is also a good connection to the Processing Matrix class.

Let's make a collection here and maybe we can split up work then...
Re: Do not divide to conquer
Reply #4 - Jun 13th, 2005, 11:12am
 
Indeed integration with those matrices is a must have.
You know what would be really nice.

If for example you have let's say an ellipse to represent a ball. That you could simply write something like.

Ball.setWeight(5);
Ball.affectedByGravity(true);
Gravity.setForce(.5);
Gravity.applyForce(true);
Friction.setForce(.3);
Friction.applyForce(true);
Wind.applyForce(false);
... and so on

This would be nice.
But for the momemt we have to make the vector library as robust, polymorphic and all other stuff they try to learn us at school.

Splitting work is crucial. For example I'm not that good a physics cause I did'nt had lessons about it yet.

We could use this post to distribute the work, set some loosy deadline ( no stress here, but maybe before version 1 of processing ).

Re: Do not divide to conquer
Reply #5 - Jun 13th, 2005, 9:12pm
 
I thought a while about your examples of a well usable physics environment. That's not that simple, as Processing's objects are only frame based, i.e. they won't exist the next frame. So we would have to build our own objects, which could be anything. Maybe the best is to build an physicsObject class, where you can attach processing shapes and primitives to and that can be inherited and formed to what ever object you want.

Back to the vector class. Which way should we go? In fact I don't see the point in splitting vectors up in 2D and 3D, but I also think that vectors with more than 4 elements (4 for matrix usage) are not necessary for graphics programming.

Sometimes I wonder, if it would be much easier to use and expand things like http://geosoft.no/software/ (under Geometry). All that stuff has been done a million times, so our goal should be more to make it work with all the processing things. Again like your examples.

Very interesting would also be a collision class. Collision of objects, rays and objects, rays and planes, etc...
Re: Do not divide to conquer
Reply #6 - Jun 13th, 2005, 9:46pm
 
The way you can extend dimensions is just polymorph all your vector classes from a single dimension and up. Past three dimensions, if someone really wants to have that, they can polymorph that some more.


So you start with a 1D "vector" (basically a scalar), that can have springs attatched etc. This is actually useful.

From that, you expand to a second dimension.

And from that, you expand to yet another, third dimension.


Just a thought.

I've been doing a lot of vector library writing and physics coding lately so I thought maybe I'd add some input.
Re: Do not divide to conquer
Reply #7 - Jun 13th, 2005, 10:21pm
 
I've took a quick like into the geometry class of geosoft.no.

We already have most of the stuff.

There are not that much operation you can perform on vectors.

I think that my library ( always give the credits to Robert Penner ) cover most of the operation.

The only limitation is that it only work on 2d ( not that great ) and the 3D.
So we could merge it with David Heubers FVector library. His library can control vector from 0 till N. We already have a great vector library.

Just to enumerate

Add - Substract  - Multiply - Divide - Negate - Scale  - RotateX (deg) - RotateY (deg) - RotateZ (deg) - Rotate XY (deg) - Rotate XYZ (deg) - Normalize - setMagnitude - getMagnitude - update x , y or z - reset - zero - clone - dot - cross ...

His library has then omitting the stuff already listed above

rotateX Y or Z in radians - equals - isZero - squaredMagnitude.
Plus the ability to construct vector from 1 till N

I mean come guys we already have it..

Then mflux has a physics library with methods like

mass - fluidFlow - world borders - affectField - Springs - massRotation - SpringForces ...

Andrew has 3D physics

Gravity - Springs ( people like those ) ...

The only thing left now

it to find a simple but beautiful way to connect all these components.

For my part I will extend my library to accept vectors from 1 till N like the VectorF library.

After thats done. Some people may want to check it cause java isn't my mother language ( <- new expression ) to add some fancy error checking.

After that's done the vector library is ready.

Then someone has to put the physic system above.

Then we'll have to think of a way to connect it somehow to the matrix library of processing ( the tricky part ). Maybe with some help of Ben or Reas.

I'm open to all suggestions. I'm here to learn. I did'nt finish my studies yet. So people with more experience do not hesitate to post some comment or tips.

Re: Do not divide to conquer
Reply #8 - Jun 14th, 2005, 2:57am
 
If you have a phyics class thats connected with processing, tehn the easiest way to include that is just to draw objects on the scene?

What do you mean by linking this proposed class with the matrices? If you have a class, and objects, which contains values about position/motion at a point in time, then all you need do is draw their representation in a 3D or 2D world. This would work fine in the existing p5 world without any modification: x, y and z coordinates are the only requirements.

I'd imagine colliding two objects using the physics engine as follows:

void setup() {
phyController c = new phyController(this);
phyObj num1 = (x1, y1, z1);
phyObh num2 = (x2, y2, z2);
num1.setVelocity(24, radians(20), radians(90), radians(0));
num2.setVelocity(12, radians(20), radians(0), radians(1);
}
Re: Do not divide to conquer
Reply #9 - Jun 14th, 2005, 9:24am
 
Well what I mean with linking to the matrices is this.

For Example:

Vector3D v = new Vector3D(10,40,-1); // notice the z-coordinate
Vector3D motion = new Vector3D(0,0,-3);

void setup()
{
//usual stuff here
}

void draw()
{
  v.add(motion); //but since i'm adding the z-coordinate when I draw an ellipse I have to do
translate(0,0,v.getZ());
ellipse(v.getX(),v.getY(),10,10);
}

The same holds for rotation.

Re: Do not divide to conquer
Reply #10 - Jun 14th, 2005, 3:20pm
 
Ok, I will try to think about that matrix stuff. I hope I find some time for that soon.

Btw. it's nice to see my surename morph from post to post. It's gone form Huebner to Heubner and now it's Heuber Smiley. I think I should better put my nick into those classes, that I put online...  Wink
Re: Do not divide to conquer
Reply #11 - Jun 14th, 2005, 4:40pm
 
Zackasa, you can do that with existing vector classes. What I was saying is we already have 3-dimensional tracking of points, and drawing objects in procesing is straight forward.

//instead of:
translate(0,0,v.getZ());
ellipse(v.getX(),v.getY(),10,10);

// you'd be better of doing:
translate(v.getX(), v.getY(), v.getZ());
rotate(v.getXDirection(), v.getYDirection(), v.getZDirection());
ellipse(0, 0, 10, 10);

* Because if you rotate a shape then you want to have it rotated around its central point which means moving the draw matrix first and then rotating. I added the fictional function getXDirection(); as a way of tracking the rotation on an object. I'm not sure how you'd store this information in a motion vector. Perhaps in the same was as the camera(..,..,..,..,..,.., upX, upY, upZ); variables?

So back to myT's point, we already have functionality for storing vector points but nothing worthy of writing a whole libary for (debatably) - so what motion/physics methods and data-structures can we provide for users?
Re: Do not divide to conquer
Reply #12 - Jun 14th, 2005, 8:57pm
 
can one get back the location of a point after transformation? I thought processing had something like this?

For example

point(5,5) <-- this is your starting point

but instead we write

translate(50,25,30);
rotate(radians(45),radians(35),radians(0));
translate(100,0);
point(5,5);

Now we have just completely changed where our starting point is. After all of that transformation, is there a way to retrive where point(5,5) ACTUALLY is?


The reason I ask is that if this can be done, a lot of shortcuts can be written using processing's native transform matrices and thus possibly become much faster.

Anything to do with modelX modelY modelZ?
http://processing.org/reference/modelX_.html
Re: Do not divide to conquer
Reply #13 - Jun 14th, 2005, 9:07pm
 
Also, I believe that most people can agree with me here in proposing the vector library to be completely seperate and independant from the physics library. The opposite is probably not true, as physics is a pain to program without any form of vector constructions...

We might also want to look at existing C++ physics packages written by others. A lot of them focus on easily enabling someone to write things that have articulated skeleton creatures, thus have things like bones, levers, pistons, in addition to springs and simple gravity/kinematics.

Finally, once a library like this is finished, I'd imagine it would be extremely daunting for any sort of beginner to physics (or even vector) programming to absorb. Is there any way to make this extremely beginner friendly? Or is this not even an issue? Basically: what is the goal here? Write a library for developers like ourselves? Or try to build a library so more people (from diverse fields) can enjoy the freedom that we have when working with vectors or writing physics sims?
Re: Do not divide to conquer
Reply #14 - Jun 17th, 2005, 11:51pm
 
I will begin the vector library this summer.
Page Index Toggle Pages: 1