What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

WoWMathHelper.IsBehind() - misleading description of arcRadians.

strix

New Member
Joined
Feb 13, 2010
Messages
442
Reaction score
18
PHP:
        //
        // Summary:
        //     Returns a boolean indicating whether you are behind a target. A parameter
        //     indicates the wideness of the cone used to test.
        //
        // Parameters:
        //   me:
        //     Position of me.
        //
        //   target:
        //     Position of target.
        //
        //   targetFacingRadians:
        //     Facing of target in radians.
        //
        //   arcRadians:
        //     The arc to test against in radians. PI is the default value.
        public static bool IsBehind(WoWPoint me, WoWPoint target, float targetFacingRadians, float arcRadians = 3.14159f);

Please add to documentation that arcRadians defines "in front" arc, not "in behind" arc.
IsBehind.webp
Arrow - facing
Red - arcRadians cone you pass to function,
Green - where it returns true,


Tested it on Training Dummy moving around step by step in "walk mode" with PI*0.8 and PI*1.2.
First one had true/false border slightly in front and second slightly behind, exactly the other way you would expect it to work.
Obviously on first one i couldn't use Backstab, but it still returned true.


In extreme cases:
Right now when you want to check "exactly behind" with PI/6 arc (30 degrees) it will do exactly opposite and return true anytime you are not "exactly in front".
To actually check "exactly behind" you need to pass 2*PI - PI/6 - 330 degrees arc.

imo best way to "fix" the function would be adding clear statement in description.
 
Last edited:
PI is the default value for arcRadians, this should make you think that combining "isBehind" and "PI" means PI is exactly behind the target...
 
PI is the default value for arcRadians, this should make you think that combining "isBehind" and "PI" means PI is exactly behind the target...
PI equals 180 degrees - whole behind area, 2*PI makes 360 degrees - right now is exactly behind, 0 makes it exactly in front.
PI.webp
You should have it on math :P


It's exactly the same for behind and facing function, while for behind more logical would be passing behind-cone, not facing-cone.
 
Last edited:
What about if you consider 0 as "orientation 0", thus where the WoWObject is facing, and thus making PI the opposite? Your drawing fails of objectivity: you're considerating an angle different than 0 (PI/2, or 90?) as "orientation zero", which is substantially subjective to your way of observing the usual trigonometric circle. But we usually start from 0, this is clearer if you see a sin or cos graph.

According to you if you want to stay on the right of the object, you should use arcRadians = 0: does it make sense?
 
Is it really so hard to understand?
PI.webp

arcRadians is the arc with it's middle right in front of target (WoWUnit.Rotation)
meaning that half of it goes to left (WoWUnit.Rotation - (arcRadians/2))
and other half of it goes to right (WoWUnit.Rotation + (arcRadians/2))

Basically you're defining wideness of IsFacing cone in IsBehind function.

For IsBehind() the middle of arc should be placed exactly behind (WoWUnit.Rotation + Math.PI), so you would define the wideness of IsBehind cone in IsBehind function.
 
Last edited:
Back
Top