I was having trouble with a bug I couldn’t figure out earlier trying to use groups (basically the Blender Geometry Nodes version of a function – inputs and outputs). I was having trouble debugging it so I used stored attributes instead of having the inputs and outputs re fed into the repeat geometry node (Blender’s version of a loop).
Using stored attributes (basically a way to assign variables to geometry in Geometry Nodes) I was able to see in the viewer the different geometry and inputs (as stored attribute variables on the geometry points). I was working on lasers and reflection (using the Laws of Reflection equation I found searching Google that Gemini AI helped me comprehend). It uses the dot product – trying to understand linear algebra better – had a good tutorial on Brilliant.com.
It uses the dot product of the normal of the reflection surface subtracted from the incoming vector.
Blender might not be seen really as Matlab or math software but it has pretty good ability for 3D graphing. Nice to have built in materials including emissive ones, compositing to give lights a glowing effect, and a built in video editor to add sound. Reminds me of my old TI 83.
Learning curve for Geometry Nodes might be a bit steep for some I have years of programming in Java and other languages. Geometry Nodes is a node based way to give programmatic function to existing 3D Models (also known as meshes). Instead of calling a function moveObjectTo(X,Y,Z) you use a Transform Geometry node or Set Position node and give a vector of 3 points (X, Y, Z).
It is interesting the light doesn’t bounce off directly at the normal – a line that goes perpendicular or orthogonal to the plane – opposite of parallel – sticking up from the face of the mesh. Cross product is useful for lines directly on the plane from the normal. If your palm is facing the ground, the ground like while typing on a keyboard, the normal of the top of your hand would be a line pointing towards the ceiling.
In my render the planes rotate changing the position of where the incoming vector hits the planes. I used a reflective material which helps with the effect. The reflective material is not what is redirecting the beam in my render – the programmatic computation using Geometry Nodes and the dot product is what helps reposition the beam. The redirection is dependent upon the normal but not the normal.
i = incoming vector
n = normal
r = outgoing vector
. is the dot product operation on the vectors, dot product gives one number not a vector like cross product is worth of note, that one number is then multiplied by all components x, y, and z in the n, normal vector the * represents that operation.
r = i – 2 * n * (n . i)
In Geometry Nodes there is a Vector Math utility node that may be set to Scale which multiplies all components by a specific number – such as the result of a dot product.
Vector Math utility node also has a Dot Product setting that takes two vectors and provides one number which I then connected to the Scale node. The multiplication by 2 also may be accomplished through the Scale node. I actually just multiplied the dot product (which is one value by 2) before connecting it to the Scale node. I finally subtracted the value out of that Scale node from i, the incoming vector which gives r, the outgoing vector.
I used the Raycast node to get the Normals using the incoming vector (Ray direction) and provided the source position from where the laser initially starts. I computed the points and then used the Curve to Points node, then Curve to Mesh node with a profile that was a Circle curve to give it a visible radius. Then I used the set material node on that curve with the emissive property set to 4.
I used the compositing Bloom node – in the compositing part of the user interface – might be new for older blender users where bloom was just a checkbox on Eevee.
The following might help people understand the concepts of normals, dot product, and cross product better.
The normal, n is the green line pointing out of the plane.
Vectors sometimes written like <x,y,z>.
The blue lines are the dot product components of the normal – n . <1,0,0> is dot product of x component of the normal, y . <0,1,0> is dot product of y component of the normal, n . <0,0,1> is the dot product of the z component of the normal.
I use the cross product to help get the line on the plane (the red line) from the normal (green line) which I then rotated to make look like a counterclockwise clock.
Note: Being from a programming background I have also seen vectors as arrays which make it somewhat common for me to use [ ] instead of angle < > brackets. Arrays many times denoted as [v1, v2, v3], meshes for certain APIs might operate this way and might contain more values like alpha value for determining visibility.
pos = [v1,v2,v3,alpha], objectPosition[] = [0,0,0,1]
Also of note, while vectors as lines are useful to be seen they also convey information about direction and magnitude. Where does it point and at what strength – which is useful for unseen vectors like velocity and acceleration. A character on a video game might have a vector of their velocity, which direction they are going and how fast like on a racing game – yet there will be no visible line.