PDA

View Full Version : "Dot Product" -- usefull analogies?

jeric_synergy
09-04-2011, 01:21 PM
Rebel Hill kindly posted a near-half-hour intro to the Spot Info node, thanks for that.

Whilst demo-ing some stuff he used some vectors, and incidentally used the "Dot" node, as in "Vector Dot Product".

For NON-MATHEMATICIANS (hell, I can't even spell "mathematician"-- tnx, splckh!) , or at least ME, the demo became tough going as the first mention of "cosign". However, I have a theory that I could wrap my head around "dot product" if it were given a friendlier, animator-friendly label.

So, my analogy here is: I have NO real idea what the "Screen" transfer mode is really doing in Photoshop, I just know that when I apply it, "no pixel will become darker than it already is, but it may become lighter".

In RH's demo, it seemed, and forgive me if I'm wrong, what the dot product node was outputting was the 'similarity' of the two vectors, at least in direction. Mathematically that may be laughable, but if a non-mathic animator wants to use it that way and it does at some level work that way, that would be a helpful to conceptualize it. Ummmm, does it?

XswampyX
09-04-2011, 01:31 PM
This might help. :)

The dot product is in green.

RebelHill
09-05-2011, 05:34 AM
Im not sure I really see how having an "animator friendly" name for the dot product function would help... After all, you could call it William if you really wanted... but william would still be the cosine of the angle between the 2 input vectors... and anyone familiar with dot product would have a hell of a time trying to find the node, by effectively making its name less descriptive of what it does, (uness u plan on calling it "cos-angle between").

The screen example you mention illustrates this point wonderfully...

Now screen... is basically the same as ADD... the reason its named differently (and yet you still have an add mode) is because adding colours doesnt work properly in gamma corrected space, only in linear, so screen is a tool created to give an effect ike add wold in linear space, but working in gamma 2.2 space (anyhow... thats really unimportant, the point is in a perfect world youd always be in linear space and such an effect would be obtained through an add function, screen is just a tool to try and give the same sorta effect in the gamma 2.2 space most things occupy).

What is important... is that SCREEN... basically IS ADD!!

And surely that's more descriptive of what you see... and easier to understand... Because the reason pixels get lighter, never darker, is because the values (effectively the brightness values) of the top layer pixels are being ADDED to the values of the bottom layer pixels. If a pixel in the top layer is black (value 0), then adding that to the pixel beneath produces no change... hence, since pixels cant be darker than black (or lower value than 0) then only positive numbers can possibly be added to the bottom layer, so pixels can only become brighter.

So I would suggest that therefore screen is an example of poor naming... as you have to apply it and try and observe whats happened too see that very bright areas of the screened (top layer) image were having more effect than midtone ro shadow areas. But were it called add... itd be obvious from the name.

So you say yourself that you have no idea what screen is doing, and so Id wager that itd be clearer were it known to you as add.

Sensei
09-05-2011, 07:50 AM
btw, diffuse shading is reverse of dot product between light sample direction and spot info smoothed normal vector.

diffuse = -dot_product( spotinfo_normal, light_sample_direction );
If it's >0.0 then it's diffuse, otherwise it's translucency.

You can try building such node tree simulating it. Distant light has constant light sample direction (so use Const > Vector), Point light has:
light_sample_direction = Normalize( spot_world_position - light_world_position );

The other light types has multiple samples per spot, so they would be quite hard to simulate in node tree.

lardbros
09-05-2011, 08:26 AM
btw, diffuse shading is reverse of dot product between light sample direction and spot info smoothed normal vector.

diffuse = -dot_product( spotinfo_normal, light_sample_direction );
If it's >0.0 then it's diffuse, otherwise it's translucency.

You can try building such node tree simulating it. Distant light has constant light sample direction (so use Const > Vector), Point light has:
light_sample_direction = Normalize( spot_world_position - light_world_position );

The other light types has multiple samples per spot, so they would be quite hard to simulate in node tree.

Ha, this helps it all sink in ;)

I understand what Jeric is trying to say... he doesn't just want a simpler name, but maybe a way to get it to click in an arty brain...

I also watched Rebel's video and yes, it explains what vectors are, and what to plug in to get the gradient effect based on a null object... just doesn't really show what is going on in 3d space with the vectors etc... I can't imagine what getting all those angles and comparing them, and then using the result is ACTUALLY doing. Anywhere I can see a 3d representation of a dot product etc?

Thanks and kudos to rebel for doing the vid, it all helps... I need some kind of visual representation of what the hell is going on with all those vector angles... my brain hurts :)

Lightwolf
09-05-2011, 09:34 AM
I understand what Jeric is trying to say... he doesn't just want a simpler name, but maybe a way to get it to click in an arty brain...

How about a vector algebra course for artists then?
Essentially entry high-school level but leaving out the parts that aren't directly relevant (i.e. proofs for example).

Mind you, even that would require a certain basic knowledge of maths... I.e. knowing the 4 basic arithmetic operations.

Cheers,
Mike

lardbros
09-05-2011, 10:26 AM
How about a vector algebra course for artists then?
Essentially entry high-school level but leaving out the parts that aren't directly relevant (i.e. proofs for example).

Mind you, even that would require a certain basic knowledge of maths... I.e. knowing the 4 basic arithmetic operations.

Cheers,
Mike

I was never taught vector math at high-school/secondary school... maybe this is where the issue lies? Comprehensive schools, as we call them in the UK didn't do this when i was at school. In fact my maths teacher was appalling.

I have an understanding of maths, and on more than a basic level... and I'm sure everyone will know the four arithmetic operations... just that some people's brains aren't mathematical.

The same goes for more mathematical people, some of them struggle with their handwriting and spelling... the ones i know anyway. It's just the way the brain works. Like asking me to sketch a horse from memory would be very, very easy... to someone of more technical skill may find this really hard.

It's hard to try and explain to a group of people who largely understand these areas, and get them to 'un-understand' them. :) Same as trying to teach me how to not be able to paint etc

Lightwolf
09-05-2011, 10:38 AM
I was never taught vector math at high-school/secondary school... maybe this is where the issue lies? Comprehensive schools, as we call them in the UK didn't do this when i was at school. In fact my maths teacher was appalling.
Well, last time I checked at least trigonometry was GCSE material. So one could assume that people know that a sine/cosine is and at least have a grip of 2D geometry.
"Could" .... ;)

I have an understanding of maths, and on more than a basic level... and I'm sure everyone will know the four arithmetic operations... just that some people's brains aren't mathematical.
Yeah, but that's a lot less people than is often assumed. A lot. In many cases it's more related to teaching in context (which is something we have in this topic).
There's a few interesting studies on the subject (not maths, but computer programming) - more hands on teaching (coding media as opposed to abstract problems) increases the percentage of people passing the course by a massive degree. And (in the case of the study) it was a course taught to all students of a college (not just CS majors).

Mind you, a lot of this reasoning is a bit too simplistic for me. Probably because I suck equally at everything...
On the other hand, the few people that I know personally that I would put in the truly "artistic" category tend to excel in more technical areas as well (or at least have a solid grasp of it).
I might just know more "polymaths" than "savants" though ;)

Cheers,
Mike

lardbros
09-05-2011, 10:55 AM
Anyone who struggles with vector maths... go here:

http://chortle.ccsu.edu/VectorLessons/vectorIndex.html

Some of this stuff is FINALLY making sense. Knew I wasn't as stupid as I feel in here...

some real fundamentals being dealt with on this site... it's VERY rudimentary stuff, but skip to the later sections and it begins to make sense! :)

Wish I'd been taught this stuff at school, it would have helped no end!

Lightwolf
09-05-2011, 10:59 AM
Wish I'd been taught this stuff at school, it would have helped no end!
Considering your first post I would expect you to have skipped the lessons though - you probably had no use for it at the time.
(This is where physics as a course comes in... it's a little more hands on and you get to actually use vector maths to compute something that happens in the real world).

Cheers,
Mike

lardbros
09-05-2011, 11:13 AM
Well, last time I checked at least trigonometry was GCSE material. So one could assume that people know that a sine/cosine is and at least have a grip of 2D geometry.
"Could" .... ;)

Yeah, but that's a lot less people than is often assumed. A lot. In many cases it's more related to teaching in context (which is something we have in this topic).
There's a few interesting studies on the subject (not maths, but computer programming) - more hands on teaching (coding media as opposed to abstract problems) increases the percentage of people passing the course by a massive degree. And (in the case of the study) it was a course taught to all students of a college (not just CS majors).

Mind you, a lot of this reasoning is a bit too simplistic for me. Probably because I suck equally at everything...
On the other hand, the few people that I know personally that I would put in the truly "artistic" category tend to excel in more technical areas as well (or at least have a solid grasp of it).
I might just know more "polymaths" than "savants" though ;)

Cheers,
Mike

I never had a good maths teacher at school... she was shockingly bad, I never enjoyed going through text books solving problems repeatedly, and then moving onto the next section and never revisiting the old stuff until exam time, the stuff never sinks in. When it came to placing people in the 'sets' or streams for the classes the next year, we had an exam that decided where we went... I thought, 'time to do well'... got 100% but never got put in the top class... and then never really recovered. :D

It's odd, the talented artists that I know are almost dyslexic with numbers (or discalculia as the correct term), and have no grasp on maths at all. Yet are very gifted in writing and painting, sculpting etc. The opposite being our programmer at work, very, very gifted engineer, and programmer, yet horrendous handwriting, and very dyslexic.

lardbros
09-05-2011, 11:17 AM
Considering your first post I would expect you to have skipped the lessons though - you probably had no use for it at the time.
(This is where physics as a course comes in... it's a little more hands on and you get to actually use vector maths to compute something that happens in the real world).

Cheers,
Mike

Which post was that?

Ha, no... I was very good at school, never missed a single class... wasn't a private education though, state schools aren't the greatest in Devon :D

Now, physics and biology I was great at... odd eh? :)

Actually, I'll correct myself... the school was good, just some of the teachers really didn't have a clue!

zardoz
09-05-2011, 11:28 AM
the company where I work bought this and I can say it's pretty good
http://fxphd.com/courses#MTH101

hurley
09-05-2011, 11:40 AM
Whenever I need a refresher or to learn more about a math subject, I head over to Khan Academy (http://www.khanacademy.org/). The videos are short(10/15 min) and presented in a down-to-earth unintimidating way by someone who is *really* good at teaching.

-Steve

jeric_synergy
09-05-2011, 12:51 PM
I understand what Jeric is trying to say... he doesn't just want a simpler name, but maybe a way to get it to click in an arty brain...
THANK you.

I also watched Rebel's video and yes, it explains what vectors are, and what to plug in to get the gradient effect based on a null object... just doesn't really show what is going on in 3d space with the vectors etc... I can't imagine what getting all those angles and comparing them, and then using the result is ACTUALLY doing.

Kids are usually first taught that subtraction is 'taking away' from a quantity.

Later, 'subtraction' is reframed as "finding the difference". This is a useful reframing of the concept.

I suspect this is applicable to the dot product operation: what is a reframing of it that reveals its utility to the non-mathematically inclined?

What artists hear when math majors speak..... (http://s173.photobucket.com/albums/w57/spn_imgs/?action=view&current=blahblah.jpg&newest=1)

+++++++++++

Hurley, thanks for the pointer to Khhhaaannnnnnnnnnnnnn!

Red_Oddity
09-05-2011, 03:23 PM
As Steve pointed out, the Khanacademy has some really clear vids on the subjects
For example, the dot product : http://www.khanacademy.org/video/vector-dot-product-and-vector-length?playlist=Linear%20Algebra

The whole Linear Algebra section of that site is very well done, and very easy to follow.

Red_Oddity
09-05-2011, 03:32 PM
What is important... is that SCREEN... basically IS ADD!!.

Kind of yes, and kind of no, it's actually quite straight forward.

Screen mode is basically inverting both layers, then multiplying them and then inverting the result again.

So, 1 - ((1 - top layer) x (1 - bottom layer))

lardbros
09-05-2011, 03:40 PM
Thanks for the link to Khan's videos Steve ... These will help for sure. I've been going over all this stuff, and the more I study the more I understand... Wish I'd been pointed towards this stuff before. It's going to be a slog, but worth it.

jeric_synergy
09-05-2011, 04:14 PM
Kind of yes, and kind of no, it's actually quite straight forward.
So, you don't see that "kinda yes kinda no" and "quite straight forward" aren't actually compatible???

RebelHill
09-05-2011, 04:31 PM
The point isnt how screen computes the effect, the point is its common usage. If using images in 2.2 space, you ADD one directly over the other, the very bright areas burn out (consider compositing ens flares for instance). If ur in linear space, this doesnt happen, and brights add together much more naturally.

So screen is commonly used because its method for "adding" gives a similar effect to what a true add would, in a correct linear space.

So "sorta yes/no" is a fair answer technically, but in terms of relating the name to an achieved effect on the image... its, straightforwardy... add.

Red_Oddity
09-05-2011, 04:58 PM
The point isnt how screen computes the effect, the point is its common usage. If using images in 2.2 space, you ADD one directly over the other, the very bright areas burn out (consider compositing ens flares for instance). If ur in linear space, this doesnt happen, and brights add together much more naturally.

So screen is commonly used because its method for "adding" gives a similar effect to what a true add would, in a correct linear space.

So "sorta yes/no" is a fair answer technically, but in terms of relating the name to an achieved effect on the image... its, straightforwardy... add.

I wasn't debating the point you where making, merely pointing out the math that goes behind it to show why it isn't simply an 'add' function, i didn't feel to explain why there is such a thing as a screen blend mode, as you already explained that correctly.

Red_Oddity
09-05-2011, 05:00 PM
So, you don't see that "kinda yes kinda no" and "quite straight forward" aren't actually compatible???

Not sure how to remark on this besides, kind of yes and kind of no? :D

RebelHill
09-05-2011, 05:11 PM
I wasn't debating the point you where making,

Well, tbh, I think u kinda were and u kinda werent...

Anyway.

My contribution to trying to get this gap between "artist" and "nodes" bridged somehow or other...

Red_Oddity
09-07-2011, 06:57 AM
Well, tbh, I think u kinda were and u kinda werent...

Anyway.