Bounce Angle Formula

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
Okey. I tried with this formula but didn't work. I'm trying to make a bounce angle.
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Facing of Unit1[(Integer A)]) Greater than or equal to 180.00
    Then - Actions
        Set RM_Angle[(Integer A)] = (540.00 - (Facing of Unit1[(Integer A)]))
    Else - Actions
        Set RM_Angle[(Integer A)] = (360.00 - (Facing of Unit1[(Integer A)]))


This trigger works great. Except in some cases, it can't check if the wall is either south or north, west or right. Example with this code, let's say the red line is 45 degrees, which means it's reflection should be 315 degrees. And in this case it works great.

bamd1.png

But when I use this formula and try to bounce to the south direction, it went like this.

bacf5.png

The red line is still 45 degrees, but this time it also reflect 315 degrees, right in the wall, the black line. But it should have bounced 135 degrees, the white line.
 

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
so, if you took 45 as the angle
45 - 180 = -135
2x-135 = -270
180+(-270) = -90
-90 = 270 degree reflection (with regards to angles, -90 = 270 you can add 360 if you want)

That doesn't seem right :S
 

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
And I didn't get it. Updated the first post to make it more clear.
 

NaPzt3R

You can change this now in User CP.
Reaction score
38
Code:
Set variable position_x to (Cosine(angle property)*x-Sine(angle property)*y)
Set variable position_y to (Cosine(angle property)*y+Sine(angle property)*x)
Move to coordinates position_x and position_y
Here's a fomular that might help. I can't help more than that. Sorry. :)
(Is there cosine and sine functions in Wc3?)

Off-topic:
@OneBadPsycho
Oh halløj broder.
 
F

FViral

Guest
I might be an idiot but it seems as though your problem lies in that the second bounce is acting exactly like the first. Maybe you need to develop a way to detect the orientation of the cliff.

Also, aren't all angles relative?
So isn't you initial bounce incoming at 135 degrees and bouncing at 225 degrees?
 

THE_X

New Member
Reaction score
49
wc3 does not use a 360% method its a 180 and -180, but it converts it to the same degree so whatever the facing angle of it x2 will be the correct angle
 

Caedin88

New Member
Reaction score
1
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Terrain pathing at ((Position of (UR UNIT)) offset by 25.00 towards RM_Angle[(Integer A)] degrees) of type Walkability is off) Equal to True
    Then - Actions
        Set RM_Angle[(Integer A)] = (RM_Angle[(Integer A)] + 180.00)
    Else - Actions
        Do nothing

Tell me if this works, Im anxious to know if it does... It works in my head lol.
 

Caedin88

New Member
Reaction score
1
If RM_Angle[(Integer A)] is 90, would the output be 270 (90+180), which in that case isn't true?

Yeah if it bounces at 90 degrees and there is a wall there then it becomes 270, I don't see what you are saying.

It basically says calculate your bounce, then if there is a wall in that direction then reverse your bounce... for example, if it comes in like the picture at -45? then his stuff makes it becomes -135, which is right for the first picture, but for the 2nd it doesn't work, but if u add this conditional it will say, wait theres a wall in -135 direction, add 180 and you get -135 + 180 which = 45 which is correct. But it won't alter the value if the wall isn't there, thus still leaving it correct for the first scenario.
 

OneBadPsycho

10100111001
Reaction score
93
Yeah if it bounces at 90 degrees and there is a wall there then it becomes 270, I don't see what you are saying.

It basically says calculate your bounce, then if there is a wall in that direction then reverse your bounce... for example, if it comes in like the picture at -45? then his stuff makes it becomes -135, which is right for the first picture, but for the 2nd it doesn't work, but if u add this conditional it will say, wait theres a wall in -135 direction, add 180 and you get -135 + 180 which = 45 which is correct. But it won't alter the value if the wall isn't there, thus still leaving it correct for the first scenario.

I mean: If you stand and throw a ball into a wall at 90 degrees and the wall is facing like this: |. Would the ball go back then, with your trigger ?

---->|
---->|
---->|

EDIT: Oh, I see your point now. ^^
 

OneBadPsycho

10100111001
Reaction score
93
----> is 0 degrees not 90, so thus


----> | 0 degrees
<---- | 180 degrees

My bad, but I have this trigger:
Code:
Move Spell
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in SpellUg and do (Actions)
            Loop - Actions
                Set LocSU = (Position of (Picked unit))
                Set AngleSU = (Facing of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Terrain pathing at (LocSU offset by 25.00 towards AngleSU degrees) of type Walkability is off) Equal to True
                    Then - Actions
                        Set AngleSU = (AngleSU + 180.00)
                    Else - Actions
                Set MoveLocSU = (LocSU offset by 10.00 towards AngleSU degrees)
                Unit - Move (Picked unit) instantly to MoveLocSU
                Custom script:   call RemoveLocation (udg_LocSU)
                Custom script:   call RemoveLocation (udg_MoveLocSU)
                Custom script:   set udg_AngleSU = 0

and it doesn't work, the units just sticks to the wall.
 

Caedin88

New Member
Reaction score
1
Because your trigger updates ever 0.01 seconds it is saying like this.

X = unit
| = wall


Okay there is a wall 25 units offset in the direction of X( reverse direction )
---> X |

0.01 seconds later (Direction is reversed by the unit has only moved 10 units, so thus 25 units to the right is still a wall, so thus reverse direction again.

My advice, switch it to this and see if it works...

Code:
Move Spell
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in SpellUg and do (Actions)
            Loop - Actions
                Set LocSU = (Position of (Picked unit))
                Set AngleSU = (Facing of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Terrain pathing at (LocSU offset by 25.00 towards AngleSU degrees) of type Walkability is off) Equal to True
[B]and BOOLEANVARIABLE is true[/B]
                    Then - Actions
                        Set AngleSU = (AngleSU + 180.00)
                        [B]BOOLEANVARIABLE = false[/B]
                    Else - Actions
                Set MoveLocSU = (LocSU offset by 10.00 towards AngleSU degrees)
                Unit - Move (Picked unit) instantly to MoveLocSU
                Custom script:   call RemoveLocation (udg_LocSU)
                Custom script:   call RemoveLocation (udg_MoveLocSU)
                Custom script:   set udg_AngleSU = 0

Code:
Untitled Trigger 002
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Set BOOLEANVARIABLE = true

If you want MUI make booleanvariable an array and use custom value to specific.
 

OneBadPsycho

10100111001
Reaction score
93
Because your trigger updates ever 0.01 seconds it is saying like this.

X = unit
| = wall


Okay there is a wall 25 units offset in the direction of X( reverse direction )
---> X |

0.01 seconds later (Direction is reversed by the unit has only moved 10 units, so thus 25 units to the right is still a wall, so thus reverse direction again.

My advice, switch it to this and see if it works...

Code:
Move Spell
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in SpellUg and do (Actions)
            Loop - Actions
                Set LocSU = (Position of (Picked unit))
                Set AngleSU = (Facing of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Terrain pathing at (LocSU offset by 25.00 towards AngleSU degrees) of type Walkability is off) Equal to True
[B]and BOOLEANVARIABLE is true[/B]
                    Then - Actions
                        Set AngleSU = (AngleSU + 180.00)
                        [B]BOOLEANVARIABLE = false[/B]
                    Else - Actions
                Set MoveLocSU = (LocSU offset by 10.00 towards AngleSU degrees)
                Unit - Move (Picked unit) instantly to MoveLocSU
                Custom script:   call RemoveLocation (udg_LocSU)
                Custom script:   call RemoveLocation (udg_MoveLocSU)
                Custom script:   set udg_AngleSU = 0

Code:
Untitled Trigger 002
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Set BOOLEANVARIABLE = true

If you want MUI make booleanvariable an array and use custom value to specific.

It doesn't work, but maybe Draphoelix figured it out in the meantime.
 

Caedin88

New Member
Reaction score
1
It doesn't work, but maybe Draphoelix figured it out in the meantime.

Never mind what i posted before its wrong, but i figured it out.

You set the angle to the units facing every pass so you for example move at 35 degrees until you hit a wall, then u move at 35+180, but the very next time u move again at 35. You cannot declare Set AngleSU = (Facing of (Picked unit)) in your trigger, it must be done elsewhere.

Also units don't turn instantly they take time, so when u do a trigger at 0.01 seconds you get problems if moving in the Facing of the unit, because the unit turn animation is much longer than 0.01.
 

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
Code:
Set AngleSU = (AngleSU + 180.00)

Will not work. What if it's in 45 angle, and you throw it on a wall that is in the south? Then it should bounce back at 135, which is 180-45 and not 45+180 which is 225. My formula is okay, except that it can't check where it hits, south of the wall, or right of the wall. Using +180 is completely wrong.

I'm using a slide trigger, don't worry about the facing. But if you throw at 35, it should bounce back at 145 degrees if thrown at a wall in the south, and 325 degrees if thrown at a right wall. I don't see how you got it to 115.

Edit: Oh you talked to One. But still, 180+ is wrong.
 

Caedin88

New Member
Reaction score
1
Code:
Set AngleSU = (AngleSU + 180.00)

Will not work. What if it's in 45 angle, and you throw it on a wall that is in the south? Then it should bounce back at 135, which is 180-45 and not 45+180 which is 225. My formula is okay, except that it can't check where it hits, south of the wall, or right of the wall. Using +180 is completely wrong.

I'm using a slide trigger, don't worry about the facing. But if you throw at 35, it should bounce back at 145 degrees if thrown at a wall in the south, and 325 degrees if thrown at a right wall. I don't see how you got it to 115.

Edit: Oh you talked to One. But still, 180+ is wrong.

I ment to add my conditional AFTER your system, your system calculates the reflect angle, which is right.

But look at your second picture, if it hits the south wall if you add 180 to the actual reflection line then you get the correct angle.

Also you can't throw at 45 degrees and hit somthing in the south, its not possible... you are going north.

You can throw at -45 and hit the south or aka 315 and hit a wall in the south.

You see you will never get 45 + 180 because a 45 angle is moving northeast, thus you cannot hit a wall on the south side.

Your sense of direction is off.
 

Caedin88

New Member
Reaction score
1
bacf5.png

The red line is still 45 degrees, but this time it also reflect 315 degrees, right in the wall, the black line. But it should have bounced 135 degrees, the white line.

The red line is at 315 not 45, the reflect is at 225 degrees not 315 and the white line, the correct reflection is at 45. Warcrafts directional system starts with 0 being directly East and 180 being directly West of the unit.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top