# Point of intersection

Get help using Construct 2

### » 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

### » 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

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

### » 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

### » 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

### » Sun Oct 07, 2012 10:23 pm

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

### » 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

### » 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.
B
160
S
48
G
80
Posts: 7,237
Reputation: 61,502

### » 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

### » 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
B
160
S
48
G
80
Posts: 7,237
Reputation: 61,502

Next