# [Solved]Translating 46 degrees into this formula

Status
Not open for further replies.

#### Ugabunda

Level 11
Hi guys,

I'm using the explanation from here (below the trigger) to identify a secondary target that is within a facing angle of a primary target.

@Dr Super Good wrote that one should rather use this formula:

It should be
• (Cos((Sector facing - (Angle from Loc1 to Loc2)))) Greater than or equal to 0.766
Yes the simplification holds true but the 2 lines of code given do not produce the same result.

Can someone who understands how to calculate angles in WC3 explain what "0.766" in degrees is please?
I want the "angle of sector origin" to be 46 degrees. What value is the equivalent of this with the formula above?
(and can I somehow calculate this in Excel for next time?)

Cheers

***
Anyway, here's how to pick units within circular sector
• Set Loc1 = <Circle origin point>
• Custom script: set bj_wantDestroyGroup = true
• Unit Group - Pick every unit in (Units within 600.00 (<Circle radius>) of Loc1 matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
• Loop - Actions
• Set Loc2 = (Position of (Picked unit))
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Acos((Cos((<Circular sector facing> - (Angle from Loc1 to Loc2)))))) Less than or equal to <40.00> - half of the angle at sector origin
• Then - Actions
• //Put actions for units within sector here
• Else - Actions
• Custom script: call RemoveLocation(udg_Loc2)
• Custom script: call RemoveLocation(udg_Loc1)

#### Nichilus

Level 24
They talked about the angle being 40 degrees. Cosine of 40 degrees is ~0.766
You can check any online calculator like Cosine Calculator | cos(x) calculator to see that cosine of 46 degrees is ~0.695

#### Ugabunda

Level 11
Thank you - solved

Status
Not open for further replies.

Replies
4
Views
583
Replies
76
Views
10K
Replies
16
Views
896
Replies
4
Views
522
Replies
10
Views
606