 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
John VanSickle wrote:
> Patrick Elliott wrote:
>> Ok, first off, here is what I have to work with:
>>
>> VecNorm = Normal for the vector.
>> VecMag = Magnitude of the vector.
>> Rot2Face = VecNorm(0,1,0) * VecMag.
>> Rot2Left = VecNorm(1,0,0) * VecMag.
>> Wind = returns a value of how "big" a force is blowing in x,y,z.
>> GetRot = Current rotation of the object.
>> SetForce = Set XForce, YForce and ZForce effecting the object.
>>
>> Now, what I need to be able to do is take the objects rotation, figure
>> out which way its "facing", then negate any movement that pushes it
>> the opposite direction. This can be simple when in a fixed
>> orientation, facing the same direction as the winds X, or Y. I just
>> check if the wind vector is negative, I.e., blowing opposite the +X
>> direction the object is facing, and throw out, or reverse the value,
>> so its now blowing +X, instead of -X. This is however completely
>> useless if/when trying to make it move in an unknown orientation.
>
> Take the dot product of the pushing force vector (not normalized) and
> the vector for the facing object (normalized), and check the sign. If
> the sign is negative (force and facing opposed to some degree), then
> multiply the dot product by the normalized value of the pushing force,
> and then subtract this from the pushing force, to yield a vector that is
> perpendicular to the pushing force.
>
> Regards,
> John
Ok, so umm, basically, like:
objnorm = VecNorm(GetRot);
windnorm = VecNorm(wind);
xdot = Wind.x * objface.x;
ydot = Wind.y * objface.y;
if xdot < 0
Wind.x -= xdot * windnorm.x;
if ydot < 0
Wind.y -= ydot * windnorm.y;
SetForce (Wind);
Now, I think this just reverses the force, right, so if I wanted to make
it got the reverse way, I would double the result of the dot product *
the force, so it move the reverse direction, not just negates it?
--
void main () {
if version = "Vista" {
call slow_by_half();
call DRM_everything();
}
call functional_code();
}
else
call crash_windows();
}
<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models,
3D Content, and 3D Software at DAZ3D!</A>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Patrick Elliott wrote:
> Ok, first off, here is what I have to work with:
>
> VecNorm = Normal for the vector.
> VecMag = Magnitude of the vector.
> Rot2Face = VecNorm(0,1,0) * VecMag.
> Rot2Left = VecNorm(1,0,0) * VecMag.
> Wind = returns a value of how "big" a force is blowing in x,y,z.
> GetRot = Current rotation of the object.
> SetForce = Set XForce, YForce and ZForce effecting the object.
>
> Now, what I need to be able to do is take the objects rotation, figure
> out which way its "facing", then negate any movement that pushes it the
> opposite direction. This can be simple when in a fixed orientation,
> facing the same direction as the winds X, or Y. I just check if the wind
> vector is negative, I.e., blowing opposite the +X direction the object
> is facing, and throw out, or reverse the value, so its now blowing +X,
> instead of -X. This is however completely useless if/when trying to make
> it move in an unknown orientation.
>
> Hmm. To simplify, assume that we are dealing with a wall that is the
> same "rotation" as the object itself, and that the object is a hanging
> cloth. I need to be able to determine when/if the wind vector is
> producing a push that is "towards" the wall, then invert it when that
> happens, so that the hanging blows "Away" from the wall, but the left to
> right movement needs to be the same as it would have been. So, in the
> simplest terms, where the facing is +X:
>
> hanging.rot = <0,0,0>
> if wind.x < 0
> wind.x *= -1;
> SetForce(wind);
WARNING: Untested code below.
Your code in POV-Ray SDL:
#declare vCloth = <1, 0, 0>; // Cloth normal
#declare ClothRotation = <0, 0, 0>;
#if (vWind.x < 0)
#declare vWind.x = -vWind.x;
#end // if
SetForce(vWind)
This would have been better:
#declare vCloth = <1, 0, 0>;
#declare ClothRotation = <0, 0, 0>;
#declare vCloth = vrotate(vCloth, ClothRotation);
#if (vdot(vWind, vCloth) < 0)
#declare vWind = -vWind;
#end // if
SetForce(vWind)
> but how the hell do you do this if its like this?
>
> hanging.rot = <10,30,0>
> if ??????
>
> I am guessing that the VecNorm will come into play, but I have no damn
> idea how. lol
Just put
#declare ClothRotation = <10, 30, 0>;
- into my suggestion above.
> Oh, and, just to make things more stupid, some bozo decided that euler
> vector can't be multiplied in the system I am working with. You can
> convert to a quaternion rotation, then do it, but not <1,2,3> * <3,2,1>.
> :p You can however do vect1.x = vect2.x * vect3.x, multiplying each
> value separately.
It's quite common that such vector multiplications are not defined, as
they are seldom used.
> Note, I am not sure if I need z or not. I am not currently using it, but
> I suppose there may be cases where it could effect the result.
If you do successive transformations to the cloth, then code like this
can be used:
#include "transforms.inc"
#declare vCloth = <1, 0, 0>; // Cloth normal
#declare ClothRotation = <10, 30, 0>;
#declare ClothPosition = <2, -3, 5>;
#declare ClothTransformation =
transform {
rotate ClothRotation
translate ClothPosition
}
/*
#declare MoreClothRotation = <0, 45, 0>;
#declare ClothTransformation =
transform {
ClothTransformation
rotate MoreClothRotation
}
*/
#declare vCloth = vtransform(vCloth, ClothTransformation);
#if (vdot(vWind, vCloth) < 0)
#declare vWind = -vWind;
#end // if
SetForce(vWind)
Be careful if the resulting transformation matrix of the transformation
is non-orthogonal, e.g. like it is when doing non-uniform scaling.
For such transformations, see:
"Transforming normals - CGAFaq"
http://www.cgafaq.info/wiki/Transforming_Normals
"Normal Transforms"
http://www.gignews.com/realtime020100.htm
--
Tor Olav
http://subcube.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tor Olav Kristensen wrote:
> Patrick Elliott wrote:
...
>> I need to be able to determine when/if the wind vector is
>> producing a push that is "towards" the wall, then invert it when that
>> happens, so that the hanging blows "Away" from the wall, but the left
>> to right movement needs to be the same as it would have been. So, in
>> the simplest terms, where the facing is +X:
...
I did not read the above thoroughly enough.
But unfortunately I do not have time right now to show you how
to do this. Maybe later.
Btw.: I did not notice that John VanSickle has already replied.
Maybe his answer helped you.
--
Tor Olav
http://subcube.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tor Olav Kristensen wrote:
> Tor Olav Kristensen wrote:
>> Patrick Elliott wrote:
> ...
>>> I need to be able to determine when/if the wind vector is producing a
>>> push that is "towards" the wall, then invert it when that happens, so
>>> that the hanging blows "Away" from the wall, but the left to right
>>> movement needs to be the same as it would have been. So, in the
>>> simplest terms, where the facing is +X:
> ...
>
> I did not read the above thoroughly enough.
>
> But unfortunately I do not have time right now to show you how
> to do this. Maybe later.
>
> Btw.: I did not notice that John VanSickle has already replied.
> Maybe his answer helped you.
>
Yes, you more or less confirm what he said, sort of. Though, I am still
waiting for a confirmation from him that my pseudocode is right. There
is no "vdot" function available in what I am working with, since its not
POVRay, so I have to do some calculations manually. :(
--
void main () {
if version = "Vista" {
call slow_by_half();
call DRM_everything();
}
call functional_code();
}
else
call crash_windows();
}
<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models,
3D Content, and 3D Software at DAZ3D!</A>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Patrick Elliott <sel### [at] npgcable com> wrote:
> There
> is no "vdot" function available in what I am working with, since its not
> POVRay, so I have to do some calculations manually. :(
The dot product of vectors is very trivial to calculate.
http://en.wikipedia.org/wiki/Dot_product
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Patrick Elliott <sel### [at] npgcable com> wrote:
>> There
>> is no "vdot" function available in what I am working with, since its not
>> POVRay, so I have to do some calculations manually. :(
>
> The dot product of vectors is very trivial to calculate.
>
> http://en.wikipedia.org/wiki/Dot_product
>
Uh, wait.. Thought dot product in this case was the equivalent of matrix
multiplication, that page implies that the vector results in a single
value, not another vector... So, what I posted in my second reply to
John was wrong?
--
void main () {
if version = "Vista" {
call slow_by_half();
call DRM_everything();
}
call functional_code();
}
else
call crash_windows();
}
<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models,
3D Content, and 3D Software at DAZ3D!</A>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
This should work, it totally negates the direction of the wind force if
hitting the "front" of the object.
objnorm = VecNorm(GetRot);
dot = wind.x * objnorm.x + wind.y * objnorm.y + + wind.z * objnorm.z;
if dot < 0
wind = -wind;
SetForce (wind);
Or did you want only the component of the wind perpendicular to the wall to
be negated?
if dot < 0
Wind = wind - 2 * dot * objnorm;
Or did you want the component of wind perpendicular to the wall to be zero
(as I think John explained)?
if dot < 0
Wind = wind - dot * objnorm;
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Patrick Elliott <sel### [at] npgcable com> wrote:
> Uh, wait.. Thought dot product in this case was the equivalent of matrix
> multiplication, that page implies that the vector results in a single
> value, not another vector... So, what I posted in my second reply to
> John was wrong?
You are probably confusing it with the cross-product.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
scott wrote:
> This should work, it totally negates the direction of the wind force if
> hitting the "front" of the object.
>
> objnorm = VecNorm(GetRot);
> dot = wind.x * objnorm.x + wind.y * objnorm.y + + wind.z * objnorm.z;
> if dot < 0
> wind = -wind;
> SetForce (wind);
>
> Or did you want only the component of the wind perpendicular to the wall
> to be negated?
>
> if dot < 0
> Wind = wind - 2 * dot * objnorm;
>
> Or did you want the component of wind perpendicular to the wall to be
> zero (as I think John explained)?
>
> if dot < 0
> Wind = wind - dot * objnorm;
>
Actually, these are helpful, especially since they explain where I got
something wrong about what the dot product does... Nimrods on the
explanation pages for their system describe * as the dot product
function, but then show you doing stuff like <0.54,0.0,0.0,-0.3> *
<1,2,3> and still ending up with a 4 argument vector, not a single
float... Real confusing if you don't know how dumb it is.
As for what I would like to do. Either a) make the component
perpendicular to the wall zero, *OR* a better option, since such things
still billow and move when blow on directly too, "reverse" the part
perpendicular to the wall, so it acts as though the wind was blowing
from the opposite direction. Thus, either one of your last two solution
is the right one. Well, except for the lame ass fact that I am not sure
I can multiply a vector and a number and get a vector, instead of the
engine whining about invalid types.. However, I think that only happens,
absurdly enough, when multiplying two non-rotation vectors (i.e., those
not yet converted to quaternions. A conversion that, ironically, would
render the information worthless in the context I need to use it, since
the force vector isn't a rotation... :p)
Anyway. Thanks. I kind of figured that doubling the value would reverse
it, rather than just zeroing it, but the two contradictory definitions
of what the frack dot product meant was throwing me off. Now that I
think of what it actually does, its bloody obvious.
--
void main () {
if version = "Vista" {
call slow_by_half();
call DRM_everything();
}
call functional_code();
}
else
call crash_windows();
}
<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models,
3D Content, and 3D Software at DAZ3D!</A>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Patrick Elliott <sel### [at] npgcable com> wrote:
>> Uh, wait.. Thought dot product in this case was the equivalent of matrix
>> multiplication, that page implies that the vector results in a single
>> value, not another vector... So, what I posted in my second reply to
>> John was wrong?
>
> You are probably confusing it with the cross-product.
>
They are confusing it with cross-product. Guess their Wiki has it wrong. :(
--
void main () {
if version = "Vista" {
call slow_by_half();
call DRM_everything();
}
call functional_code();
}
else
call crash_windows();
}
<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models,
3D Content, and 3D Software at DAZ3D!</A>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |