To calculate the line intersection points between two shapes we use the ILcd2DLineIntersectionTopology interface, as illustrated in the example below:

import java.util.Formatter;
import java.util.Locale;

public class LineIntersectionTutorial {
public static void main(String[] args) {
// Create the ellipsoid.
// For this sample, it is hardcoded here.
// In practice, the ellipsoid used by all shapes in the program should be used.
// In a cartesian topology, no ellipsoid is needed.
TLcdEllipsoid ellipsoid = new TLcdEllipsoid();

// Create two shapes.
// For this sample two simple triangles are created.
// In practice, these ILcdShape instances could originate from any source.
TLcdLonLatPolygon polygon1 = new TLcdLonLatPolygon(new TLcd2DEditablePointList(
new ILcd2DEditablePoint[]{
new TLcdLonLatPoint(0.0, 0.0),
new TLcdLonLatPoint(10.0, 20.0),
new TLcdLonLatPoint(20.0, 10.0)
}, false), ellipsoid);
TLcdLonLatPolygon polygon2 = new TLcdLonLatPolygon(new TLcd2DEditablePointList(
new ILcd2DEditablePoint[]{
new TLcdLonLatPoint(11.0, 12.0),
new TLcdLonLatPoint(5.0, 4.0),
new TLcdLonLatPoint(12.0, 0.0)
}, false), ellipsoid);

// Create the topology.
ILcd2DLineIntersectionTopology topology = new TLcdEllipsoidalBasicBinaryTopology(ellipsoid);

// Find the line intersections points.
ILcdPoint[] intersectionPoints = topology.lineIntersection(polygon1, polygon2);

System.out.println("Intersection points:");
for (ILcdPoint intersectionPoint : intersectionPoints) {
// always use points to avoid confusion with the coordinate separator
Formatter formatter = new Formatter(Locale.US);
System.out.println(formatter.format("(%.2f, %.2f)", intersectionPoint.getX(), intersectionPoint.getY()));
}
}
}