MATHS - COSINE
|Home||Tutorial Links||My Tutorials||Sample Materials||Freebies|
MATHS - COSINE
Poser provides us with three functions from trigonometry. Second in the list is the Cosine maths function. Here we are going to look at what the Cosine function produces in Poser (click here for an article on the trigonometry). The Cosine function produces very similar results to the Sine function, so check that article out for some other suggestions that work with both.
For any single number, cosine returns a number between -1 and 1. Most of the time in Poser, we will be using another node to control the sine function, often a U or V node, but we can use just about any node.
Figure 1 shows what happens when we feed the cosine function a U or V node - we get a regular wave, returning values between -1 and 1, and repeating endlessly (the green line shows Value_1=0.5, purple is Value_1=1, red is Value_1=2 and Blue is Value_1=4. The higher we set Value_1, the quicker our cosine wave will repeat). Value_2 is ignored by the cosine function.
The main difference between cosine and sine for our purposes is where the wave starts - the sine wave begins at zero, and climbs, while Cosine begins at one and falls. If we plug an image map into a cosine function we produce an inverted greyscale (see below).
Figure 2 shows the sine function repeating three times. The middle Multiply node is not strictly necessary - I have included it here for clarity. Our U node provides a number than runs smoothly from 0 to 1. We plug the output from the U node into Value_1 of our Multiply node. Value_1 is set to PI (3.141593 in this case). We use Value_2 to control what multiple of PI we are going to feed to our Sine function. Here, we have set Value_2 to six. Our original range of 0 to 1 has now been turned into a range of 0 to 18.849558. When we feed that into our Sine function, we get three complete sine waves. Note that the sine way produces results between 1 and -1. The node preview shows us values between 0 and 1 as shades of gray, but ignores the negative numbers, showing all negative numbers as black.
Sometimes we will want to shift the output of our sine or cosine waves from the range -1 to 1 into the range 0 to 1. We can do that with a simple Add maths function. Plug the output of the cosine or sine wave into the Value_1 input, and set Value_1 to 0.5. This has halved the range of the wave to -0.5 to +0.5. Set Value_2 of the Add function to 0.5 and we now have a wave in the range 0 to 1, ready to be used to control blender nodes or any other function that doesn't want (or like) negative numbers.
Another interesting effect can be gained by plugging the output of our sine or cosine wave into an Abs maths function. Negative numbers are returned as positive numbers, so those parts of the wave that were below zero now appear inverted above zero.
Cosine can be used as a to produce an inverted grayscale version of a picture. Because of the shape of the cosine wave, the darker areas would be emphasised in the final result. To get the best results out of this, set Value_1 of the cosine node to PI/2 (1.5707963265), at which point any zeros in the input node become ones, and any ones become zeros (black becomes white and white becomes black). Higher values here would turn the brighter colours black (look at the blue curve in figure 1 to see why).
Cosine (and sine) can produce some very interesting displacement maps.