Old Coffee "vnorm" term to python

digging into my age old C4D files I found a setup with a xpresso coffee node that uses the "vnorm" for vector normalization in multiplication of two vectors. What is the python equivalent for that? I have basically no python skill so help is highly appreciated. Thank you!

Hello @ceen,

Thank you for reaching out to us. It is always best to share code to clear up ambiguties because vnorm does not ring a bell for me. COFFEE was just wrapping the C++ API just as Python does. And I am not aware of a method vnorm for the vector types of Cinema 4D, either you are misinterpreting the script, or it is really, really old, something like R6 or so (did COFFEE even exist then?).

However, this sounds very much like vector normalization. You should just look at c4d.Vector in our docs, but long story short, this is how normalization works in the Cinema 4D API (since pretty much forever), here at the example of Python but C++ is more or less the same:

>>> import c4d
>>> v: c4d.Vector = c4d.Vector(1, 2, 3)
>>> v
Vector(1, 2, 3)
>>> n: c4d.Vector = v.GetNormalized() # Get a normalized copy of #v
>>> n
Vector(0.267, 0.535, 0.802)
>>> m: c4d.Vector = ~v # Tilde is the operator shorthand for GetNormalized.
>>> m
Vector(0.267, 0.535, 0.802)
>>> v.Normalize() # This normalizes the instance itself, i.e., #v itself is modified.
>>> v
Vector(0.267, 0.535, 0.802)


MAXON SDK Specialist

@ferdinand Thank you! you can find it in the old coffee help "using matrices" tutorial section:


My own code is ridicoulusly simple:

ang = ( vnorm(vector1) * vnorm(vector2)) ;

Just looking for a python "vnorm"