[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


how do you calculate an area between 3 points the same way you can calculate an area in a square (x-1y1,x1y1,x-1y-1,x1y-1)
note that this is not the LITERAL area, it CANT be a single number, it has to be a sort of less-than more-than thing (like the previous paranthesis) (it will obviously be more complicated than simple less thans and more thans due to the uneven angles but im trying to get something adjacent to it while still not taking too much computation)
i wouldnt ask here normally, but ive asked in several different forums and such and none of them seemed to understand what i was talking about for some reason, which is EXTREMELY weird considering many of them code and work with math as a hobby or a living.

its like i'll say the "area" of a triangle and i'll even go out of my way to make like an entire tangent about how i am not talking about the mathematical definition of "area" im talking about this different thing i dont know the name of and then they'll just put all of that aside and go "oh yeah dude the area of a triangle is blah blah blabbity blah that ends up in returning a SINGLE number" and i just ಠ_ಠ
>>
It sounds like what you're hunting for isn't the numerical area at all, but a region descriptor, essentially a way to represent "the set of points inside this triangle" in inequalities, similar to how a bounding box can be written:

x_min <= x <= x_max
y_min <= y <= y_max


For an arbitrary triangle though, it won't be simple min/max ranges because of the angled edges. The standard trick is to use half‑space inequalities built from the edges:

1. Take your three vertices A(x1,y1), B(x2,y2), C(x3,y3).
2. For each edge (say AB), compute the line equation through those two points.
- Line AB: (y2 - y1)(x - x1) - (x2 - x1)(y - y1) = 0
3. Decide which side of that line contains the third vertex (C). That tells you whether your inequality should be >=0 or <= 0 for "inside."
4. Do this for all three edges. You'll end up with three inequalities describing exactly the triangular region.

So instead of one scalar "area," you've got something like:

f_AB(x,y) >= 0
f_BC(x,y) >= 0
f_CA(x,y) >= 0


That's basically what axis‑aligned rectangles are doing but generalized, they just happen to reduce neatly into simple less‑than bounds when sides are aligned with axes.

If computation cost is scary:
- You can precompute those coefficients once per triangle and then checking if a point lies inside becomes just 3 multiplies + adds and some comparisons => very cheap.
- If you only need approximations, yes, snapping down to an axis‑aligned bounding box still works, but that's usually coarser than people want.

tl;dr: Represent it as intersection of half spaces (= inequalities). That matches what you're saying about wanting a "less than / greater than" analogue rather than raw numeric area.

Do you need this for testing point‑in‑triangle membership or are you thinking more along collision regions / clipping?
>>
>>106771754
>>>/sci/
>>
>>106771754
You're probably underage but you'd like 3blue1brown's linear algebra videos.
>>
>>106771754
what do you mean it can't be a single number? Your solution is representable as some string of ASCII characters which can be encoded into a number
Or do you mean that the number only syntaxtically encodes the solution not semantically? There is a semantic link to the solution and a simple one at that.

Anyway there isn't any equation for a triangle if that's what your asking
https://www.youtube.com/watch?v=4K-Jx914NcQ here is an accessible video.
>>
>>106771817
THANK YOU!!! this is the best response ive ever gotten!!
im very self taught in math, so im not familiar with some of the phrases here, but i'll try my best to translate them into my own "math language".
im still struggling a bit though, im not entirely sure what the formula is meant to convey although i do have a few loose ideas.
i imagine youre supposed to find the center of the first line youre trying to look at, but what do you mean deciding which line contains the third vertex? like, are we making a V shape?
and from there it gets less easy to interpret things because theres a lot of directions it could be going in.
but this does seem very good and i am interested in what exactly you mean. i very appreciate this and even if you magically disappeared it'd still probably be the reply i'll try "cracking" the most heheh

also, yes! i am using this for collision regions. i know it sounds more intuitive to just create hollow shapes since rarely does a box go so fast to the point of disregarding an entire wall, but im kinda persnickety and just think itd be more fun if the collision was more "solid"

>>106771832
youre totally correct whoops. this happened last time i posted here but i didnt think much of it because when i went there it was mostly non-math scienceposting, and i figured it wasnt my place to post, but looking there now there *is* more mathposting and i just caught it at a bad time i guess heheh
at least i can ask more math questions and nobody will know its the same guy who asked two questions earlier in g >:)
>>
>>106771754
honestly i'd rather have a hundred naive threads like this popping on the catalogue than the usual shitposts
>>
>>106772181
you cant just call me naive and not tell me what i dont know!! cmon!!!!!
>>
>>106771754
NTA but imagine your points were (0,0) (4,4) and (4,0). The line equation between the first two points is y=x. If you change that equation to y>x , you'll get a region that includes everything above the line. Since your third point is (4,0) you want the region below the line which would be y<x. If you repeat this with all three lines you'll get three inequalities.
> y<x
> y>0
> x<4
Any point that satisfies all three inequalities lies within the triangle
>>
>>106771754
I did this in calculus 2
>>
>>106771754
when you rotate a triangle it will have the same area, so you rotate it (you can skip this) until two points are parallell and aligned with your axis of choice and do bh/2. what's the problem?
>>
>>106772334
i mean that asking questions in earnest is kind of naive as far as modern 4chanz go but still better than the dozen or so basedjak threads that are up at a given moment
>>
>>106771754
calculate distance between point p and triangle points a,b,c

then sum up all these distances
if the total is greater than the triangle circumference the point lies outside of the triangle area
>>
>>106772572
>>106772483
i made it very clear that i am not asking for the literal area and the formula cannot return a single number.
>>106772520
i see. i kinda just do it anyways because i think it makes the place just the slightest more interesting (plus i just tend to get better responses here due to the better social biodiversity)

>>106772414
seems good! i'll try it right now. all i'd have to do is translate y=x into its less even forme by doing like (x1+x2)-(y1+y2) (at least i think thats how you do it i havent calculated it yet)
>>
>>106772696
what do you mean exactly? it tells you if the point is within the triangle
>>
File: .png (104 KB, 1713x490)
104 KB
104 KB PNG
>>106772572
this doesn't work, there are points outside of the triangle whose sum distance to the vertices is smaller than points inside the triangle
>>
>>106772752
there are multiple posts i tagged, youre going to have to specify who (You) are
>>
File: triangle.webm (403 KB, 1156x1150)
403 KB
403 KB WEBM
>>106771754
You mean this?
>>
>>106773595
no, but pretty reasonable misinterpretation! this would be pretty simple to calculate though, almost identically to how squares do it. which i guess would fit the bill for "the same way you do with squares" haha. but no, im trying to figure out something more like these
>>106772414
>>106771817

apologies for not having any updates yet!! stuff got in the way and i feel kinda gloomy right now, but i swear i wont let it get the best of me this time!!
>>
File: sad.png (17 KB, 418x327)
17 KB
17 KB PNG
>>106773961
ok maybe it got the best of me

guess i gotta just hope this thread somehow lasts the night or something heheheh, but hey, at least if it dies itd be an opporunity to use the appropriate board..!

but that anon at the start was super helpful.. i dont wanna lose em....
>>
File: file.png (68 KB, 763x708)
68 KB
68 KB PNG
>>106771754
>>106774277
I think I understand it, and you just do the line equation for the three pairs
you know, y = mx + b but you change it to < or > depending on the points, like picrel



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.