So for each triangle rotation assign it a type. and then depending on the angle you approach from change the angle then check it's type using other.type during a collision (or whatever variable you store the other object as when you check for a collision so if you do q = collision(??) which returns the object you collided at then you'd do q.type instead)
For example from the example below lets say the top left one is assigned type = 1 at creation
so
if(other.type == 1)
{
if (direction == 0){direction = 90}
else if(direction == 90){direction =270}
else if(direction ==180){direction = 0}
else {direction =180}
// no need to compare anything since only one left is direction == 270
// by process of elimination for the else statement
}
the others would be 2 3 4 respectively and it's up to you to keep track of which is which.
https://www.dropbox.com/s/bqaqapbr0fiv50m/triangles.png
there is probably a better way which would be to give one triangle object a direction which it would rotate it's image by when it's drawn and be given the direction at creation
and then that direction would be used in the calculations instead of checking type
if (direction == 0){direction = 90 - other.direction}
else if(direction == 90){direction =270 - other.direction}
else if(direction ==180){direction = 0 - other.direction}
else {direction =180 - other.direction}
// no need to compare anything since only one left is direction == 270
// by process of elimination for the else statement
so if the top left one is direction == 0 then the bottom left one would be direction == 90 and as you can see subtracting 90 from the end result creates the same desired effects.