General Category > General Game and Application Development

question : how to reduce a percentage (40% 0.4) by...

(1/1)

RemiD:
question : how to reduce a percentage (40% 0.4) by another percentage (10% 0.1) but the other percentage (10% 0.1) is a part of the whole (100% 1.0) not of the part

let me try to clarify the above sentence :
this is to reduce the length of a vector by a certain percentage/coeff
WVector is the whole vector (100% 1.0)
BVector is a part of the whole vector before collision (say 60% 0.6)
AVector is a part of the whole vector after collision (say 40% 0.4)
say i want reduce the length of the whole vector by 10% 0.1, but i want to only apply the reduction on the AVector, so i can't just do this :
AVX = AVX*0.9 | AVY = AVY*0.9 | AVZ = AVZ*0.9
because it would remove 10% of the length of the AVector from the AVector
i want to remove 10% of the length of the WVector from the AVector

:-\

Matty:
Is the W vector in the same direction as the U vector?

If they are then you can do this:

subtract 0.1 * W vector from A vector.

RemiD:
@Matty>>i think this is as simple as you say, except i probably need to add a check to make sure the AVector length is superior to 0

thanks!

Kryzon:
Lengths, like distances, are always positive because they involve squaring some numbers.
You can't get negative numbers after a squaring / power-of-two operation.

Length = sqr( deltaX^2 + deltaY^2 + deltaZ^2 )

If any of the deltas is negative the result of their ^2 will still be positive.

---------------------
If the A vector is 40% or 0.4 of the W vector, and W vector should be reduced to 90% of what it was (it loses 10%), then...
A = 0.4 * (W * 0.9) = 0.4 * 0.9 * W
A = 0.36 * W

RemiD:
@Kryzon>>good, thanks i will try that.