26.03.2015, 19:34
Similar although didn't test that
pawn Код:
stock IsBetweenXYZ(Float: X, Float: Y, Float: Z, Float: X1, Float: Y1, Float: Z1, Float: X2, Float: Y2, Float: Z2, Float: deg = 5.0) {
new
Float: rZ = atan((Z2 - Z1) / VectorSize(X2 - X1, Y2 - Y1, 0.0))
;
return (
(-deg <= (atan2(X2 - X1, Y2 - Y1) - atan2(X - X1, Y - Y1)) <= deg) &&
(-deg <= (atan2(X1 - X2, Y1 - Y2) - atan2(X - X2, Y - Y2)) <= deg) &&
(-deg <= (rZ - atan((Z - Z1) / VectorSize(X - X1, Y - Y1, 0.0))) <= deg) &&
(-deg <= (rZ + atan((Z - Z2) / VectorSize(X - X2, Y - Y2, 0.0))) <= deg)
);
}