第八章第三十一题(几何:交点)(Geometry: Intersections)

第八章第三十一题(几何:交点)(Geometry: Intersections)

  • *8.31(几何:交点)编写一个方法,返回两条直线的交点。两条直线的交点可以使用编程练习题3.25中显示的公式求得。假设(x1,y1),(x2,y2)位于直线1上,而(x3,y3)和(x4,y4)位于直线2上。方法头:
    public static double[] getIntersectionPoint(double[][] points)
    这些点保存在 一个4x2的二维数组points中,其中(points[0][0],points[0][1])代表(x1,y1)。方法返回交点,或者如果两条线平行的话就返回null。编写一个程序,提示用户输入四个点,并且显示交点。运行示例参见编程练习题3.25.
    *8.31(Geometry: Intersections)Write a method to return the intersection of two lines. The intersection of the two lines can be obtained by using the formula shown in programming exercise 3.25. Suppose (x1, Y1), (X2, Y2) are on line 1 and (X3, Y3) and (x4, Y4) are on line 2. Method header:
    public static double[] getIntersectionPoint(double[][] points)
    These points are stored in a 4x2 two-dimensional array points, where (points [0] [0], points [0] [1]) represents (x1, Y1). Method returns the intersection point, or null if two lines are parallel. Write a program to prompt the user to enter four points and display the intersection point. See programming exercise 3.25 for example

  • 参考代码:

    package chapter08;
    
    import java.util.Scanner;
    
    public class Code_31 {
         
        public static void main(String[] args) {
         
            Scanner input = new Scanner(System.in);
            System.out.println("请输入4个点");
            double[][
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值