Finer Control of a Dot Product ?
2563 10 1- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- BabaJ
- Member
- 2042 posts
- Joined: Sept. 2015
- Offline
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
This was the help I was given on a particular issue.
Embedded in the code are questions. Instead of posting the HIP file I want to understand the theory
Embedded in the code are questions. Instead of posting the HIP file I want to understand the theory
vector target = point(@OpInput2, "P", 0); vector aim = normalize(@target - @P); v@am = normalize(target - @P); /* Why does one target attribute have "@" and the other doesn't ?*/ @facing = ceil((dot(@N, aim))); f@hitMark = rayhittest(@P,@facing,0); /* I'm hoping the rayhittest function can check if primitives are strictly parallel to the point which means because of the dot product if there are extra primitives; those primitives should not be included; I hope that was clear ? :) Shouldn't @facing be declaired as a vector or float */ @Cd = @facing; float clramp = chramp("Facing",@facing); @Cd = set(clramp,0,0);
【T】【C】【S】
- VFXLife
- Member
- 16 posts
- Joined: March 2016
- Offline
Christopher R
Why does one target attribute have “@” and the other doesn't ?
…
Shouldn't @facing be declaired as a vector or float
1. @target is referencing an attribute called “target” that lives on your geo, whereas the other “target” is a variable from line 1 that only lives inside this VEX code. Attributes require “@” notation, variables do not.
2. @facing is an integer because you're using ceil() to raise the result of the dot product to the next whole number. A dot product returns a float from -1 to 1, so ceil(dot()) will return either 0 or 1, depending on whether the aim vector is aiming more or less than 90 degrees away from the Normal vector.
EDIT: Although, since you're not declaring a type when creating @facing, it is defaulting to float, so actually it's a float value of either 0.0 or 1.0
Edited by VFXLife - Dec. 13, 2016 20:14:42
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- BabaJ
- Member
- 2042 posts
- Joined: Sept. 2015
- Offline
if
For all intents and purposes you can consider target a variable which ever way you create it.
vector target = {0,0,0};is in a vex code “window” it's always available within that window, but only there.
v@target = {0,0,0};is available both within the vex “window” and outside it, alhtough it now must be prefaced with the @ symbol and possibly additional code depending on where your using it.
For all intents and purposes you can consider target a variable which ever way you create it.
Edited by BabaJ - Dec. 13, 2016 22:50:32
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
-
- Quick Links