Hello.

I have this image first:

Notice:

1:Triangle

2:Rectangle

3:Two green dots

How do i find the two green dots position if objects exist in 2d space?

What i have is a triangle that at one point will be colliding with rectangle and i need to remove the part of the triangle that is colliding with rectangle, to do such i thought about making few triangles from the existing triangles.

I need to end up with following triangles.

The issue is i do not know how to get the green positions on the rectangle if someone would be kind to provide any kind of help or hints i would be glad i do not know from where to start.

Edit::

I made a example to show what i need calculated

I want to write function as:

void Generate_Intersetion_Points(sf::Vector4i rec, sf::Vector2i line, std::Vector<sf::Vector2i> & generatedPointsPosition);

The function would take rectangle and a line and feed intersection point intro the vector, the issue is i don't know the math required, some hints would be great to start with.

**Edited by BaneTrapper, 15 April 2014 - 03:34 PM.**