# Learning VOPSOP

## Recommended Posts

Day 8 :

Here's an idea for the dot product, some trigonometry and our beloved sin function.

Cheers,

Remi

Edited by Shinjipierre

##### Share on other sites

A little late to the party.

Having a quick go at this one. Not used the cross product yet, just dotting the vector from P to the nearest point on the cylinder with another planar vector (1,0,0) and putting that into a sin. Looks like I'm not quite there though.

Edited by wixman

##### Share on other sites

Just noticed I've written cross product instead of dot product, you don't need a cross for this, you're really close

##### Share on other sites

Just noticed I've written cross product instead of dot product, you don't need a cross for this, you're really close

Thanks! Well that's good to know - I guess it's possible to use the cross for this (?) as the length of the cross is the sin of the angle between the two vectors multiplied by their lengths

##### Share on other sites

Ok, I think I got there.

(Took the arccos of my dot, then plugged that into the sin)

Edited by wixman

##### Share on other sites

Shinji's tasks are so hard T_T

Sorry for taking so long to post but what I did was basically follow wixman's instructions, I would've never figured it out on my own. So I did some more messing around in Houdini to get an idea of what's actually going on.

Anyway, here's a screenshot;

##### Share on other sites

Hi, I'm having some trouble figuring out how to solve shinjipierre's task. I tried to apply wixman's explanations, looking for other ways but I can't figure out what I'm doing wrong.

If someone could point me in the right track, thx a lot. Here is what I have for now:

problem_Shinpierre.hip

##### Share on other sites

edit; nvm, I tweaked a few things and it looked like it's working fine until I tried moving the cylinder. What I used instead of the PC import by index was PC Import inside of an If-then block. The rest of the network was pretty much the same as yours. Also I had to increase the Search Radius on the PC Open quite a bit ;3

Also you should consider unhooking that N pipe from the VopSop's output. For some reason it's doing weird things , at least on my machine.

Edited by Georgie

##### Share on other sites

I've attached an image of my network.

Presumably, if it's not working when you move the tube around, something is wrong with the point cloud look up. Because if it finds nothing, the lines will fan out from center (0,0,0).

What the dot product is essentially doing is comparing the two (normalized) vectors, and giving the cosine of the angle between them:

1 if they're the same direction, -1 if they're opposite direction and 0 if they're perpendicular. The arccos gives the actual angle between the two vectors in radians (from 0 to pi)

I've done this in an attribvop, which has opinputs as globals making the point cloud lookup a bit simpler.

Edited by wixman

##### Share on other sites

Could someone explain me why the position of the points I try to get doesn't work using the PC import node with an if block? maybe I'm doing something wrong because he doesn't take the points of the cylinder, only the origin. Here is the modified file

Édit: you used a PC filter node, from the help, it says you get the average of the point given by the point cloud, but don't you want to get the correct position, not an average one?

problem_Shinpierre.hip

Edited by ioness
• 1

My humble try

##### Share on other sites

My humble try

Could you post an image of your result? This is pretty much the network I had in my first attempt - the size of my beams wasn't consistent without the arccos

Edited by wixman

##### Share on other sites

I'm glad to see I'm not the only one who failed at this )    I tried for hours yesterday to no avail.  Not even close all i could get was a lines going parallel to the vector I dotted with and when i added the sin function I just got two parallel lines.

Soo then I started to mess around and did this...  Its not right barely even close unless you tweak tons of parameters, but if I mess with the number of points to return on the point cloud open node the pattern vibrates and it makes a really badass tunnel effect

##### Share on other sites

I'm glad to see I'm not the only one who failed at this )    I tried for hours yesterday to no avail.  Not even close all i could get was a lines going parallel to the vector I dotted with and when i added the sin function I just got two parallel lines.

Soo then I started to mess around and did this...  Its not right barely even close unless you tweak tons of parameters, but if I mess with the number of points to return on the point cloud open node the pattern vibrates and it makes a really badass tunnel effect

Hey Captain - to be honest, the only thing that looks out of the ordinary here is the nearpt/getattrib here. We just need a vector from our current position (P) to the nearest point on the cylinder.

Also, use the 'trigonometric functions' node for the sin - the key here is to crank up the frequency to increase the number of beams.

##### Share on other sites

oooooooohhhhhhhhhhhhhhhhh    that makes sense, I couldn't figure out why I could only get blocks instead of a radial pattern.  I think near point works better then a point cloud in this instance, though subtracting the both of them just makes a cool wiggling effect

Thanks for the explanation of the math, this makes a lot more sense to me now.

##### Share on other sites

I think near point works better then a point cloud in this instance

It does! - getting a cook of 13.51ms with the nearpt setup vs a cook of 18.40ms with pcopen.

Good to know!

Edited by wixman

##### Share on other sites

Point cloud gets all the points in the search radius and returns a weighted result of all the points, near point just gets the nearest point.

##### Share on other sites

Point cloud gets all the points in the search radius and returns a weighted result of all the points, near point just gets the nearest point.

I'm pretty sure pcopen stops once it reaches the set number of points, in this case I had it set to 1.

##### Share on other sites

Yes sorry ,I was referring to whole set up, pc filter weights the points, even if its just one point it may still weight it or at minimum it has to test it if its just one point. Then return it.

Edited by captain

##### Share on other sites

Okay here's one for Day 9:

Using the intersect vop create shadows from a mesh onto a grid.  Extra credit for making it a soft shadow( you can use a second vopsop for this)

Roberts example is better you should stride to it like that |

\/

Edited by captain

## Create an account

Register a new account