平行四边形是指具有两对平行边的四边形,其中对边长度相等,对角线度量相等。
In this article we are going to find all possible coordinates of a Parallelogram.
Basically, we will find all the possible coordinates from the given three coordinates to make a parallelogram of a non-zero area. Here the three given coordinates are not fixed points and can change.
因此,如果给出三个坐标,我们可以断言只有这三个坐标可以构建一个平行四边形。

As per diagram given above, the opposite sides of a parallelogram are equal in length i.e., AD = BC and AB = CD, we can calculate the coordinates of the missing point (D) as
AD = BC
(Dx - Ax, Dy - Ay) = (Cx - Bx, Cy - By)
Dx = Ax + Cx - Bx
Dy = Ay + Cy - By
让我们开始吧!
展示给你一些实例
Instance-1
假设这三个点是 −
{a1 = 3, a2 = 2}, {b1 = 1, b2 = 0}, {c1 = 4, c2 = 2}
After finding all possible coordinates of a Parallelogram, result will be −
The (x, y) coordinates are −
0, 0
6, 4
2, 0
Instance-2
假设这三个点是 −
{a1 = 7, a2 = 2}, {b1 = 3, b2 = 0}, {c1 =0, c2 = 1}
After finding all possible coordinates of a Parallelogram, result will be −
The (x,y) coordinates are −
10, 1
4, 3
-4, -1
Algorithm
Step 1 − Declare the three coordinates of parallelogram.
Step 2 − Find the other possible coordinates using the formula.
Step 3 − Print the result.
Multiple Approaches
我们以不同的方法提供了解决方案。
通过使用静态输入值
通过用户定义的方法
让我们逐个查看程序及其输出。
方法一:通过使用静态输入值
在这种方法中,我们将把这三个点作为静态输入,并应用公式来打印结果。
Example
public class Main{ // main method public static void main(String[] args){ //Declare the three coordinates of parallelogram int a1 = 3, a2 = 2; int b1 = 1, b2 = 0; int c1 = 4, c2 = 2; //find the other possible coordinates and printing it System.out.println("The (x,y) coordinates are: "); System.out.println(a1 + b1 - c1 + ", " + (a2 + b2 - c2)); System.out.println(a1 + c1 - b1 + ", " + (a2 + c2 - b2)); System.out.println(c1 + b1 - a1 + ", " + (c2 + b2 - a2)); } }
Output
The (x,y) coordinates are: 0, 0 6, 4 2, 0
Approach-2: By Using User Defined Method
In this approach, first we will initialise a user defined method and we will take the three points as input and apply the formula to print the result.
Example
public class Main { // main method public static void main(String[] s){ //Declare the three coordinates of parallelogram int a1 = 7, a2 = 2; int b1 = 3, b2 = 0; int c1 = 0, c2 = 1; //calling user defined function func(a1, a2, b1, b2, c1, c2); } //user defined function static void func(int a1, int a2, int b1, int b2, int c1, int c2){ //find the other possible coordinates and printing it System.out.println("The (x,y) coordinates are: "); System.out.println(a1 + b1 - c1 + ", " + (a2 + b2 - c2)); System.out.println(a1 + c1 - b1 + ", " + (a2 + c2 - b2)); System.out.println(c1 + b1 - a1 + ", " + (c2 + b2 - a2)); } }
Output
The (x,y) coordinates are: 10, 1 4, 3 -4, -1
在这篇文章中,我们探讨了如何通过使用不同的方法在Java中找到平行四边形的所有可能坐标。
以上是在Java中找到平行四边形的所有可能坐标的详细内容。更多信息请关注PHP中文网其他相关文章!

JVM的工作原理是将Java代码转换为机器码并管理资源。1)类加载:加载.class文件到内存。2)运行时数据区:管理内存区域。3)执行引擎:解释或编译执行字节码。4)本地方法接口:通过JNI与操作系统交互。

JVM使Java实现跨平台运行。1)JVM加载、验证和执行字节码。2)JVM的工作包括类加载、字节码验证、解释执行和内存管理。3)JVM支持高级功能如动态类加载和反射。

Java应用可通过以下步骤在不同操作系统上运行:1)使用File或Paths类处理文件路径;2)通过System.getenv()设置和获取环境变量;3)利用Maven或Gradle管理依赖并测试。Java的跨平台能力依赖于JVM的抽象层,但仍需手动处理某些操作系统特定的功能。

Java在不同平台上需要进行特定配置和调优。1)调整JVM参数,如-Xms和-Xmx设置堆大小。2)选择合适的垃圾回收策略,如ParallelGC或G1GC。3)配置Native库以适应不同平台,这些措施能让Java应用在各种环境中发挥最佳性能。

Osgi,Apachecommonslang,JNA和JvMoptionsareeForhandlingForhandlingPlatform-specificchallengesinjava.1)osgimanagesdeppedendendencenciesandisolatescomponents.2)apachecommonslangprovidesitorityfunctions.3)

JVMmanagesgarbagecollectionacrossplatformseffectivelybyusingagenerationalapproachandadaptingtoOSandhardwaredifferences.ItemploysvariouscollectorslikeSerial,Parallel,CMS,andG1,eachsuitedfordifferentscenarios.Performancecanbetunedwithflagslike-XX:NewRa

Java代码可以在不同操作系统上无需修改即可运行,这是因为Java的“一次编写,到处运行”哲学,由Java虚拟机(JVM)实现。JVM作为编译后的Java字节码与操作系统之间的中介,将字节码翻译成特定机器指令,确保程序在任何安装了JVM的平台上都能独立运行。

Java程序的编译和执行通过字节码和JVM实现平台独立性。1)编写Java源码并编译成字节码。2)使用JVM在任何平台上执行字节码,确保代码的跨平台运行。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

禅工作室 13.0.1
功能强大的PHP集成开发环境

Atom编辑器mac版下载
最流行的的开源编辑器

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),