平行四边形是指具有两对平行边的四边形,其中对边长度相等,对角线度量相等。
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中文网其他相关文章!

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于结构化数据处理开源库SPL的相关问题,下面就一起来看一下java下理想的结构化数据处理类库,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于PriorityQueue优先级队列的相关知识,Java集合框架中提供了PriorityQueue和PriorityBlockingQueue两种类型的优先级队列,PriorityQueue是线程不安全的,PriorityBlockingQueue是线程安全的,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于java锁的相关问题,包括了独占锁、悲观锁、乐观锁、共享锁等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于多线程的相关问题,包括了线程安装、线程加锁与线程不安全的原因、线程安全的标准类等等内容,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于枚举的相关问题,包括了枚举的基本操作、集合类对枚举的支持等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Java的相关知识,其中主要介绍了关于关键字中this和super的相关问题,以及他们的一些区别,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于平衡二叉树(AVL树)的相关知识,AVL树本质上是带了平衡功能的二叉查找树,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Java的相关知识,其中主要整理了Stream流的概念和使用的相关问题,包括了Stream流的概念、Stream流的获取、Stream流的常用方法等等内容,下面一起来看一下,希望对大家有帮助。


热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3汉化版
中文版,非常好用

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

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)