questions about geometry, trigonometry functions

SanKakU

Member
Reaction score
21
"geometry, trigonometry" is what i'm trying to figure out here.

got a question about math functions with x and y reals.

actually, i don't know almost anything about those, and wish someone would make a tutorial on them.

anyway...here's the pressing question i have for now.

let's say i have a hero select a target x/y a certain distance away from him...let's say 200-750 range away.

now i want to get the math to get the x/y points for two more angles of a triangle. but i don't know anything about the math functions to do that.

let's say that there is a line for the triangle crossing with the caster's facing direction. since he's facing the direction of the target x/y when casting there...the line will cross his viewing angle...and i want to in the trigger select the points a certain distance away from there.

so let's say the spell is casted 500 range or more away from the caster. now we want to get a line to draw us a couple more points that will be closer to the caster. each a certain distance from the center of the line.
Code:
    t

p_______p


    c
something like that.
i need the math functions to be able to get those points so i can use them...also i want to be able to select targets within this triangle of the target, and 2 other points which are extrapolated from the caster's position.

of course...if the target is close to the hero, then the triangle will be drawn differently.

Code:
p_______p


    t

    c
like that

i knowthere's a tutorial
http://www.hiveworkshop.com/forums/archive/index.php/t-172620.html
there, but i don't understand it.

looks like i can find some angles...but i don't know what their degrees are! here's what i mean:

JASS:

local real uf=GetUnitFacing(SpellEvent.CastingUnit)
local real lf=uf+90.00//these two reals go left and right from the center of the
local real rf=uf-90.00//hypotanuse...thus, getting ready to form the two angles of it
local real dist=getdisr(SpellEvent.TargetX,SpellEvent.TargetY,SpellEvent.CastingUnit)
local integer lvl=GetUnitAbilityLevel(SpellEvent.CastingUnit,iac)
local real disfrocen=300.00//we will use this 3 times, twice in establishing
// the angles of the hypotanuse, and once to get the last angle.
//  the distance numbers can change, that doesn't matter what they are.
local unit xa=null
local unit xb=null
local unit xc=null
local player y = GetOwningPlayer(SpellEvent.CastingUnit)
local real tx = SpellEvent.TargetX
local real ty = SpellEvent.TargetY
if dist<500 then
set xa = CreateUnit(y, 'ospw', tx + disfrocen * Cos(lf * bj_DEGTORAD), ty + disfrocen * Sin(lf * bj_DEGTORAD), lf+180.00)
//i don't know what these functions do...i only know they seem to let me make units
//that are at an angle at a distance from a point...(Cos, Sin, bjDEG)
set xb = CreateUnit(y, 'ospw', tx + disfrocen * Cos(rf * bj_DEGTORAD), ty + disfrocen * Sin(rf * bj_DEGTORAD), rf+180.00)
set xc = CreateUnit(y, 'ospw', tx + disfrocen * Cos(uf * bj_DEGTORAD), ty + disfrocen * Sin(uf * bj_DEGTORAD), uf+180.00)
else
set xa = CreateUnit(y, 'ospw', tx - disfrocen * Cos(lf * bj_DEGTORAD), ty - disfrocen * Sin(lf * bj_DEGTORAD), lf-180.00)
set xb = CreateUnit(y, 'ospw', tx - disfrocen * Cos(rf * bj_DEGTORAD), ty - disfrocen * Sin(rf * bj_DEGTORAD), rf-180.00)
set xc = CreateUnit(y, 'ospw', tx - disfrocen * Cos(uf * bj_DEGTORAD), ty - disfrocen * Sin(uf * bj_DEGTORAD), uf-180.00)
endif
set xa = null
set xb = null
set xc = null


so here's where i'm stuck. although i can target the 3 points depending on where the target point is...how am i to calculate for what is in the triangle?

i would think that it would be good to get the degrees of the angles. but i don't know how to do that. i don't know how to get the degrees in the triangle even though with those functions which i don't even know what they do i was able to establish the angles of the triangle. i could make 3 units cast siphon mana on eachother...that would display the sides...but i have no way to know how to do anything physically with that. it's not like you could make units that try to cross that line get attacked by the line.

and what about figuring out how to make one of the 3 units face the direction that is in the middle of the other two units? like i said, i don't know how to figure out what the degrees of an angle is, so how can i cut it in half if i don't even know what it is? wouldn't the degrees of an angle depend on the distances?

hmm...well, i think i figured out kindof how to do it by reading some wiki articles about triangles.

in my code if i write it like this, then the 3 sides will be the same length...meaning that they have the same angle, which is 1/3 of 180, or 60.

they said that

c/ca=b/ba=c/ca. that's the formula.
there was another formula that made me realize that the 3 sides were the same length...lol

2d^2+2m^2=a^2+b^2
so since the line going to the far angle was 300, and it going to the other angles was both 300, that was 600times 600...or shorten it to 6x6 giving me 36. and m was c cut in half. which was what i did. and d was that first number. so it was all the same. another 36. so a and b making the 72 meant they both had to have the range of 600 each. it didn't take long after that to realize the angles all had the same degrees.

EDIT: ah...somehow the triangles aren't making sense to me...i thought i figured it out but it's somehow...i think i messed up in interpreting the calculations...meh...whatever. i guess angle of 60 for all three is close enough...
 

Laiev

Hey Listen!!
Reaction score
188
The Helper Forums > Warcraft Zone > World Editor Help > Tutorials and Resources
questions about geometry, trigonometry functions


should be



The Helper Forums > Warcraft Zone > World Editor Help >
questions about geometry, trigonometry functions


and at least make things more readable =.= no one like text wall

JASS:

local real uf=GetUnitFacing(SpellEvent.CastingUnit)
local real lf=uf+90.00//these two reals go left and right from the center of the
local real rf=uf-90.00//hypotanuse...thus, getting ready to form the two angles of it
local real dist=getdisr(SpellEvent.TargetX,SpellEvent.TargetY,SpellEvent.CastingUnit)
local integer lvl=GetUnitAbilityLevel(SpellEvent.CastingUnit,iac)
local real disfrocen=300.00//we will use this 3 times, twice in establishing
// the angles of the hypotanuse, and once to get the last angle.
//  the distance numbers can change, that doesn't matter what they are.
local unit xa=null //variable are created with nulled value -.- u don't need it
local unit xb=null //variable are created with nulled value -.- u don't need it
local unit xc=null //variable are created with nulled value -.- u don't need it
local player y = GetOwningPlayer(SpellEvent.CastingUnit)
local real tx = SpellEvent.TargetX
local real ty = SpellEvent.TargetY

    if dist<500 then
        set xa = CreateUnit(y, 'ospw', tx + disfrocen * Cos(lf * bj_DEGTORAD), ty + disfrocen * Sin(lf * bj_DEGTORAD), lf+180.00)
        //i don't know what these functions do...i only know they seem to let me make units
        //that are at an angle at a distance from a point...(Cos, Sin, bjDEG)
        set xb = CreateUnit(y, 'ospw', tx + disfrocen * Cos(rf * bj_DEGTORAD), ty + disfrocen * Sin(rf * bj_DEGTORAD), rf+180.00)
        set xc = CreateUnit(y, 'ospw', tx + disfrocen * Cos(uf * bj_DEGTORAD), ty + disfrocen * Sin(uf * bj_DEGTORAD), uf+180.00)
    else
        set xa = CreateUnit(y, 'ospw', tx - disfrocen * Cos(lf * bj_DEGTORAD), ty - disfrocen * Sin(lf * bj_DEGTORAD), lf-180.00)
        set xb = CreateUnit(y, 'ospw', tx - disfrocen * Cos(rf * bj_DEGTORAD), ty - disfrocen * Sin(rf * bj_DEGTORAD), rf-180.00)
        set xc = CreateUnit(y, 'ospw', tx - disfrocen * Cos(uf * bj_DEGTORAD), ty - disfrocen * Sin(uf * bj_DEGTORAD), uf-180.00)
    endif

set xa = null
set xb = null
set xc = null
 

SanKakU

Member
Reaction score
21
well, anyway i think i was going about it the wrong way...i was trying to make the casting point be the middle of the hypotenuse, but i think it's better to make the casting point be an angle...of course i have an idea that it might be better still...or anyway not difficult at least...to make the casting point be the middle of the triangle.

The Helper Forums > Warcraft Zone > World Editor Help > Tutorials and Resources
questions about geometry, trigonometry functions

should be

The Helper Forums > Warcraft Zone > World Editor Help >
questions about geometry, trigonometry functions

if i posted this here and it wasn't moved by a mod...it's probably because i was searching this forum for a resource that explained this. i still don't understand the functions what they do like atan atan2 and cos and sin and all that. sorry for posting in the wrong spot.
 

saw792

Is known to say things. That is all.
Reaction score
280
Clearly you haven't studied trigonometry in school yet... Start learning some basic trig and you will probably find a simpler way to do this. What you're asking doesn't really make sense, since it seems you are arbitrarily picking a distance for the horizontal line (one side of your triangle), and there seems to be no guideline as to how long the line should be and when it should be above the target and when it should be below.

Having said that:

Direction vector between target and caster:
JASS:
vx = targx - castx
vy = targy - casty
General equation of line perpendicular to this line:
JASS:
(vx)x + (vy)y = 0
Which means that given some point (x0, y0) (basically some point some distance between the caster and target that you decide) you can find other points perpendicular to the line between the target and the caster by picking a random other x and y as follows:
JASS:
vy(y - y0) = -vx(x - x0)


If you then want the perpendicular line to be a certain length (say, 300 units for example) then you can work out the angle from the caster to that point:
JASS:
theta = Atan2(300/2, D)
where D is the distance you chose for the line to be from the caster. Then you can work out the absolute angle from the axis to the two points using the angle between the caster and the target:
JASS:
gamma1 = Atan2(vy, vx) + theta
gamma2 = Atan2(vy, vx) - theta

And then you calculate the points based on the two angles and the original (x0, y0):
JASS:
hypotenuse = sqrt((300/2)^2 + D^2)
x1 = hypotenuse * cos(gamma1)
y1 = hypotenuse * sin(gamma1)
x2 = hypotenuse * cos(gamma2)
y2 = hypotenuse * sin(gamma2)


Possibly not the most efficient way, but the maths is solid.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top