java计算两条线段的交点完整代码
import lombok.AllArgsConstructor;
import lombok.Data;
import java.math.BigDecimal;
public class Test {
@Data
@AllArgsConstructor
static class Point{
private BigDecimal x;
private BigDecimal y;
}
public static void main(String[] args) {
Point p1=getPoint(3630940.601591212,39438876);
Point p2=getPoint(3630272.41274585,39441716);
Point p3=getPoint(3630016.340373975,39441636);
Point p4=getPoint(3630652.5201728526,39438848);
Point point=segmentsInstr(p1,p3,p4,p2);
if(point==null){
System.out.print(“未相交”);
}else{
System.out.print(“相交于:”+point.toString());
}
}
public static Point getPoint(double a,double b){
BigDecimal aa=BigDecimal.valueOf(a);
BigDecimal bb=BigDecimal.value