|
|
Am 22.05.2017 um 13:51 schrieb Kenneth:
> object { Block(nbLength, BSIZE.y, BSIZE.z) rotate -1*(wall_th)*y
>
> Change the minus sign to a plus sign, and it will cause the 'problem' walls to
> suddenly appear on the opposite side of the fort! That rotation entry makes use
> of your wall_th variable. Apparently, the *sign* of that rotation needs to
> flip from minus to plus, depending on how *much* rotation it specifies. (The
> problem seems to occur when an individual wall section rotates past 90-deg(?) or
> 180-deg(?) from its original orientation. It's hard to tell which is correct.
> Maybe both(?!)) Perhaps the underlying problem stems from one of these two
> lines, also in the WALL macro...
>
> #local wall_vec = <wall_vec.u, 0, wall_vec.v>;
>
> #local wall_th = degrees(acos(vdot(wall_vec,x)));
My spontaneous guess would be that the use of `acos` here might be to
blame, as it will only return values in the range from -90 to +90
degrees, losing information about the quadrant. Maybe try rephrasing
that as an expression satisfying the form `atan(A/B)`, and then use
`atan2(A,B)` instead to make sure you get the quadrant right.
I haven't fully thought it through, but I think the following should do
the trick:
#local wall_th = degrees(atan2(wall_vec.x, wall_vec.z));
(You may need to tweak the expression a bit, e.g. swapping the `.x` and
`.z`, and/or changing the sign of one or both of them.)
Post a reply to this message
|
|