#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Calculation formula...

Posts: 353Member, PRO

Hi there...

I'm looking a calculation formula for the following problem.

I have two Actors (red, green)
Actor green overlaps Actor red.
I now want to calculate what percentage of the Actor green overlaps the red.

I'm not sure if I can implement or calculate this in GS.

Did any of you have an idea?

Thanks...

• Posts: 387Member, PRO
edited August 2016

I could do it easily if it didn't matter about diagonal intersection or not, it is possible but would be annoying either way. It's all just math on math on math. If you need me to do it PM me

• Posts: 353Member, PRO

Yes, it is diagonal calculations.
I also know that it's just math...math and math:-)
The question arises for me ... if that is to act in GS

• Posts: 2,239Member

i dont think it is possible
as actors do not communicate at which x or y they are collapsing

• Posts: 1,755Member
edited August 2016

I think the Gamesalad game Puzzle Dozer by @gamesmold does something like this, so I think can be done.

• Posts: 353Member, PRO

@BBEnk said:
I think the Gamesalad game Puzzle Dozer by @gamesmold does something like this, so I think can be done.

• Posts: 1,755Member
• Posts: 353Member, PRO

it already comes close
@gamesmold can you help?

• Posts: 908Member, PRO

You could do it with some math for sure. This thread gives a bit more insight here:
http://stackoverflow.com/questions/9324339/how-much-do-two-rectangles-overlap

• London, UK.Posts: 12,820Member

Like AlchimiaStudios says, it can certainly be done with maths.

Attached is another - more mechanical - route, just drag the red rectangle around so it overlaps with the blue rectangle.

This is just thrown together to give you the idea, it could be a lot more accurate / better coded, but it gives you the basic idea.

• Posts: 738Member

@BigDave said:
i dont think it is possible
as actors do not communicate at which x or y they are collapsing

True, but you know the size of each actor, their center positions, and their rotation

• Posts: 2,784Member, Sous Chef, PRO

@Socks -- what a fun solution! Nice idea.

• London, UK.Posts: 12,820Member

@RThurman said:
@Socks -- what a fun solution! Nice idea.

Cheers, it's a bit brute-force (rather than elegant maths) but it could work with some more thought/refinement, it's a bit crude at the moment.