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:
Java Program to Implement Stack
Spring 5 and Servlet 4 – The PushBuilder
Generating Random Dates in Java
Java Program to Find the Minimum value of Binary Search Tree
Hướng dẫn Java Design Pattern – Bridge
Java Program to Implement Min Hash
Guide to WeakHashMap in Java
Spring WebFlux Filters
Java Program to Compute DFT Coefficients Directly
Constructor Injection in Spring with Lombok
How to Define a Spring Boot Filter?
Introduction to the Functional Web Framework in Spring 5
A Guide to HashSet in Java
Java Program to Implement Expression Tree
Kết hợp Java Reflection và Java Annotations
Java Program to Implement Unrolled Linked List
Integer Constant Pool trong Java
Returning Image/Media Data with Spring MVC
Sort a HashMap in Java
Guide to Spring 5 WebFlux
Java Program to Implement LinkedTransferQueue API
Java Program to Implement Radix Sort
Introduction to the Java NIO Selector
Java Program to Find All Pairs Shortest Path
Java Program to Search Number Using Divide and Conquer with the Aid of Fibonacci Numbers
Read an Outlook MSG file
Hướng dẫn Java Design Pattern – Visitor
Getting Started with Stream Processing with Spring Cloud Data Flow
Tạo ứng dụng Java RESTful Client với thư viện Retrofit
Changing Annotation Parameters At Runtime
Java Program to Implement Extended Euclid Algorithm
Giới thiệu Java 8