Point of intersection

Get help using Construct 2

Post » Sun Oct 07, 2012 8:35 pm

What's the best way to get the x and y value of the point where two objects overlap? Or is this possible? Like a point of collision type thing.
B
5
S
1
Posts: 6
Reputation: 749

Post » Sun Oct 07, 2012 9:19 pm

be more specific, which types of object intersects: line/line, line/circle, circle/circle, line/convex polygon intersection...
B
12
S
2
G
2
Posts: 96
Reputation: 1,583

Post » Sun Oct 07, 2012 9:22 pm

Line/line.
B
5
S
1
Posts: 6
Reputation: 749

Post » Sun Oct 07, 2012 9:39 pm

This is pretty tricky. Let me see if I can work something out...
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Sun Oct 07, 2012 10:09 pm

Hooray, I just did a math!

Here you are, sir!
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Sun Oct 07, 2012 10:23 pm

Awesome! Thanks!   
B
5
S
1
Posts: 6
Reputation: 749

Post » Mon Oct 08, 2012 12:37 am

here's another solution which counts line segments (not "infinite" lines)so line segments intersect not only because they are not parallel..

line-line intersection

edit: drag line end pointspodpathos2012-10-08 00:39:40
B
12
S
2
G
2
Posts: 96
Reputation: 1,583

Post » Mon Oct 08, 2012 1:50 am

I would think that self.x< object2.x ?self.x+(distance(self.x,self.y, object2.x,object2.y)/2) :self.x-(distance(self.x,self.y, object2.x,object2.y)/2) would work.
Since distance() is based on the hotspots.
Image Image
B
161
S
48
G
89
Posts: 7,345
Reputation: 66,245

Post » Mon Oct 08, 2012 3:08 am

@newt, not sure what you're getting at there. I'm interested...
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Mon Oct 08, 2012 3:59 am

The distance() between two points divided by 2, will give you a radius that you can use to get that x.
That is if both objects are of the same width, and height.
newt2012-10-08 04:01:14
Image Image
B
161
S
48
G
89
Posts: 7,345
Reputation: 66,245

Next

Return to How do I....?

Who is online

Users browsing this forum: BackendFreak and 19 guests