This is a java program to show the duality transformation of line and point. The transformation corresponds from line to point and point to line.
Here is the source code of the Java Program to Show the Duality Transformation of Line and Point. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
package com.maixuanviet.computationalgeometry;
import java.util.Scanner;
public class DualityTransformationofPointandLine
{
public static void performLineTransformation(double a, double b)
{
System.out.println("X: " + (b / a) + ", Y: " + (b * -1));
}
public static void performPointTransformation(double x, double y)
{
System.out.println("y=" + (-1 * y / x) + "x +" + (-1 * y));
}
public static void main(String[] args)
{
System.out
.println("Perform what transformation.\n1. Line Transformation\n2. Point Transformation");
Scanner sc = new Scanner(System.in);
int option = sc.nextInt();
switch (option)
{
case 1:
System.out.println("Enter the coefficients of line <y=ax-b>");
double a = sc.nextDouble();
double b = sc.nextDouble();
performLineTransformation(a, b);
break;
case 2:
System.out.println("Enter the coordinate of point <x, y>");
double x = sc.nextDouble();
double y = sc.nextDouble();
performPointTransformation(x, y);
break;
default:
break;
}
sc.close();
}
}
Output:
$ javac DualityTransformationofPointandLine.java $ java DualityTransformationofPointandLine Perform what transformation. 1. Line Transformation 2. Point Transformation 1 Enter the coefficients of line <y=ax-b> 1 2 X: 2.0, Y: -2.0 Perform what transformation. 1. Line Transformation 2. Point Transformation 2 Enter the coordinate of point <x, y> 2 -2 y=1.0x +2.0
Related posts:
Spring 5 WebClient
Java Program to Implement Interpolation Search Algorithm
Java Program to Implement a Binary Search Algorithm for a Specific Search Sequence
How to Get All Spring-Managed Beans?
Java – Random Long, Float, Integer and Double
Java Program to Generate All Possible Combinations Out of a, b, c, d, e
Hướng dẫn Java Design Pattern – Singleton
Tổng quan về ngôn ngữ lập trình java
Uploading MultipartFile with Spring RestTemplate
ExecutorService – Waiting for Threads to Finish
Checked and Unchecked Exceptions in Java
Documenting a Spring REST API Using OpenAPI 3.0
Java Program to Implement Euclid GCD Algorithm
Java Timer
Static Content in Spring WebFlux
Validate email address exists or not by Java Code
Java 8 – Powerful Comparison with Lambdas
Command-Line Arguments in Java
Cài đặt và sử dụng Swagger UI
Logging in Spring Boot
Java Program to Implement Binary Heap
Immutable Map Implementations in Java
Generate Spring Boot REST Client with Swagger
Send email with SMTPS (eg. Google GMail)
Comparing Dates in Java
Loại bỏ các phần tử trùng trong một ArrayList như thế nào trong Java 8?
The StackOverflowError in Java
Java Program to Implement Red Black Tree
Hướng dẫn Java Design Pattern – DAO
Java Program to Generate Random Partition out of a Given Set of Numbers or Characters
Java Program to Implement Trie
Hướng dẫn Java Design Pattern – Adapter