Java中根据圆心处相似弦求角度
圆是一个没有角的二维圆形图形。每个圆都有一个原点,圆上的每个点到原点的距离相等。圆的原点和圆上一点之间的距离称为圆的半径。同样,如果我们从圆的一端到另一端画一条线,并且原点位于线的中间,则该线称为圆的直径。基本上,直径是半径长度的两倍。
圆的弦是指一条从圆的一端到另一端相切的线。或者简单地说,弦是指端点位于圆上的线。弦将圆分成两部分。
根据题意,已知圆的半径和弦在圆心处张成的角,需要求弦的长度。
求弦长的逻辑 -
Angle subtended by the chord at centre = Angle subtended by another chord of same length at centre
让我们一起探索。
一些示例
示例1
假设弦在圆心处张成的角 = 60°
那么,另一条长度相同的弦在圆心处张成的角 = 60°
示例2
假设弦在圆心处张成的角 = 45°
那么,另一条长度相同的弦在圆心处张成的角 = 45°
示例3
假设弦在圆心处张成的角 = 52°
那么,另一条长度相同的弦在圆心处张成的角 = 52°
算法
步骤1 - 通过静态输入或用户输入获取弦在圆心处张成的角。
步骤2 - 使用上述逻辑找到另一条相同长度的弦在圆心处张成的角。
步骤3 - 打印结果。
多种方法
我们提供了多种方法的解决方案。
使用静态输入值
使用用户定义的方法
使用用户输入值
让我们逐一查看程序及其输出。
方法1:使用静态输入值
示例
在这种方法中,我们在程序中初始化弦在圆心处张成的角。然后,使用算法可以找到另一条弦张成的角。
import java.io.*;
public class Main{
//main code
public static void main (String[] args){
//angle subtended by chord
int angle = 52;
System.out.println("Angle subtended at the center by the chord: "+angle+" degrees");
}
}
输出
Angle subtended at the center by the chord: 52 degrees
方法2:使用用户定义的方法
示例
在这种方法中,我们获取用户输入的弦在圆心处张成的角。然后,通过将此值作为参数调用用户定义的方法,并在方法内部使用算法找到另一条弦张成的角。
import java.io.*;
public class Main{
//main code
public static void main (String[] args){
//angle subtended by chord
int angle = 40;
findAngle(angle);
}
//user defined method to find the angle subtended by another chord
static void findAngle(int angle){
System.out.println("Angle subtended at the centre by the chord: "+angle+" degrees");
}
}
输出
Angle subtended at the centre by the chord: 40 degrees
方法3:使用用户输入值
示例
在这种方法中,我们在程序中获取用户输入的弦在圆心处张成的角。然后,使用算法可以找到另一条弦张成的角。
import java.io.*;
import java.util.*;
public class Main{
//main code
public static void main (String[] args){
//Create object of Scanner class
Scanner sc = new Scanner(System.in);
//angle subtended by chord
System.out.println("Enter the angle subtended at center by the chord:");
int angle = sc.nextInt();
System.out.println("Angle subtended at the center by the chord: "+angle+" degrees");
}
}
输出
Enter the angle subtended at center by the chord: 55 Angle subtended at the center by the chord: 55 degrees
在本文中,我们探讨了如何使用Java中的不同方法,在已知相同长度的另一条弦在圆心处张成的角的情况下,找到一条弦在圆心处张成的角。
广告
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP