Tagged: processing.org Toggle Comment Threads | Keyboard Shortcuts

• frankiezafe 23:08 on 2018-04-13 Permalink | Reply Tags: itch.io ( 4 ), processing.org, release ( 2 ), tools ( 5 ), video ( 24 ), videomapping, vj

Release month continues with FlatMapper, a videomapping sketch running in processing.

Source code is here: https://github.com/frankiezafe/FlatMapper

And here is a demo video of the applicationt:

The perfect halo function.

The halo is generated by making a linear blending between the sine on a sigmoided angle (sinus1) and a standard sine (sinus2 ).

The sigmoided sine has the advantage of being powerful far from the center:

+

The main problem with this method is the very short blurred area, making it too sudden.

The basic sine method has exactly the opposite problem, tiny white area but plenty of blur.

To combine both in a smooth way, the code is slowly changing the weights of both process accordingly to the distance (pc).

The java code (processing.org), looks like this:

float pc = distance_to_center/256;
float a = pow( pc, 1.5 ) – 0.3;
float sig = 1 / ( 1 + exp( ( -8 + a * 16 ) ) );
float sinus1 = ( 1 + sin( -HALF_PI + ( sig * PI ) ) ) * 0.5;
float sinus2 = 1 – ( ( 1 + sin( -HALF_PI + ( pc * PI ) ) ) * 0.5 );
d = 255 * ( sinus1 * (1-pc) + sinus2 * pc );

• frankiezafe 16:33 on 2017-03-26 Permalink | Reply Tags: algorithm ( 13 ), code, math ( 7 ), processing.org

To generate the bocks of building based on the roads structure, the method I’m building is based on a simple idea: when you arrives at a crossroad, you take the first street on the right and you go on like this until you reach a dead-end or your starting point. If you reach your starting point, the succession of roads you took defines a block of building. In theory. This technique has been suggested by Michel Cleempoel, on the way back from school.

After a bit of preparation of the road network (removing orphan roads, having no connection with others, and dead-ends parts of the roads), the real problem arouse: how do you define right in a 3d environment, without an absolute ground reference. Indeed, I can configure the generator to use the Y axis (top axis in ogre3d) in addition to X & Z.

At a crossroad, you may have several possibilities of roads. In the research, these possible roads are reduced to 3d vectors, all starting at world’s origin. The goal is to find the closest vector on the right of the current one, called the main 3d vector in the graphic above..

The right is a complex idea, because it induces an idea of rotation. The closest on the right doesn’t mean the most perpendicular road on the right side. Let say I have 4 roads to choose from. Two going nearly in the opposite direction of the road i’m on, one perpendicular and one going straight on.

If I compute the angles these roads have with the current one, results are:

1. 5°,
2. -5°,
3. 90°,
4. and 170°.

The winner is not the 90°, but the 5° road! If I sort them, the last one must be the -5°, who is the first on the left.

3d plane from a 3d vector

The first thing to do is to define reference plane. To do so, you get the normal vector of the road by doing a cross product with the UP axis (Y axis in this case). The normal gives you a second vector, perpendicular to the road, and therefore defines a plane. Let’s call it VT plane, for Vector-Normal plane. For calculation, we need the vector perpendicular to this plane, rendered by crossing the road and its normal, let’s call it the tangent vector. Until here, it’s basic 3d geometry.

projection of 3d vectors on a plane

We can now project all the possible roads on the VT plane. These are the yellow vectors in the graphic. The math are clearly explained tmpearce on stackoverflow. Implemented in processing, it gives:

```      float d = othervector.dot( tangent );
PVector projectedvector = new PVector();
projectedvector.mult( d * -1 );
```

We are nearly done!

angle between 3d vectors

The projected vectors will help the angle calculation. Indeed, the current vector and the projected ones being coplanar, they share the same normal. The way to get the angle between 2 coplanar vectors is described by Dr. Martin von Gagern, on stackoverflow, once again. See Plane embedded in 3D paragraph for the code i’ve used.

And… tadaaammmm! The number rendered by the method is the angle i was searching for, displayed in degrees in the graphic above.

• frankiezafe 23:39 on 2016-12-16 Permalink | Reply Tags: algorithm ( 13 ), graph theory ( 2 ), Peel ( 21 ), processing.org, research ( 10 )

Looking for loops in networks.

It’s seems very simple, but when i’ve started to search for a programmatic way to solve this, you ends up with a kind of complexity that seems much too high compared to the problem.

After a bit of research, i found the Rocha Thatte method. It is a very elegant way to detect “cycles” in “directed graphs”. Description in wikipedia.

This is a js implementation, based on the java version, used to study the implementation.

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r