## perjantai 24. elokuuta 2012

### Dot product explained differently

Dot product is one of the "tools" that is hard to avoid if one is programming anything related to 3D. I have found several attempts to explain the dot product. However, many of them are strictly mathematical. The mathematical explanation of dot product is useful only for those who can read and understand mathematical presentations. This presentation is not aimed to those people :)

This is a one way to see the dot product from a very practical point of view.

Let's see a figure from Wikipedia about dot product:

The figure shows the relation of the dot product and the cosine. For example, if you have two unit vectors (eg. vectors with length 1) and the angle between them is 45 degrees, then the result of dot product is the same as cosine of 45, which is about 0.7

Now, let's draw the same figure a little bit differently.

The vector B is now a plane normal. Now, the dot product of vector A and the plane normal gives us the distance between the vector (a point) A and the plane defined by the normal (yes, a normal itself defines a plane where one of the plane's points is in the origin. Let's call that a "normal" plane").

This is very handy indeed. The dot product can be used as a tape measure.

But this works only if our plane goes through the origin. What if our plane is not in origin? Well, the solution is simple. The distance from any point to any plane is:

the distance between the point and the "normal" of the plane + the distance from the plane to the "normal" plane.

More formally:

dotProduct(the point, the normal ) + dotProduct(the point of the plane, the normal)

I hope this helps someone.

## tiistai 14. elokuuta 2012

### Updating Blender script -> 2.63 Pyramidaze! in action.

## Blender is evolving...

Blender is evolving fast which is a good thing. A bad thing is that also its Python API is changing thus breaking old scripts. But updating old scripts is a good way to learn the new API.

So, I updated my really old pyramidaze script. This simple script iterates through selected faces of the object and adds a pyramid top of them (see image above).

Blender now supports NGons which means that the API has changed also. There were two major changes in this case. The way polygons are accessed has changed due the NGons. Secondly, the API does not provide a polygon center any more, so center must be calculated in the script.

You can find a blend file including the script from here.
http://www.opendimension.org/blender_en/blends/pyramidaze_2.63.blend