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 14 Record Keyword
HttpClient 4 – Follow Redirects for POST
Guide to WeakHashMap in Java
Spring Boot - Batch Service
Model, ModelMap, and ModelAndView in Spring MVC
Java Program to find the number of occurrences of a given number using Binary Search approach
Java Program to Implement Binary Search Tree
How to Delay Code Execution in Java
Overview of the java.util.concurrent
Returning Image/Media Data with Spring MVC
Find the Registered Spring Security Filters
Java Program to implement Associate Array
Java Program to Check if a Given Set of Three Points Lie on a Single Line or Not
Servlet 3 Async Support with Spring MVC and Spring Security
Java Program to Implement Adjacency List
Spring Security 5 – OAuth2 Login
HttpClient Timeout
Java Program to Implement Tarjan Algorithm
Xây dựng ứng dụng Client-Server với Socket trong Java
Guide to Spring Cloud Kubernetes
An Introduction to ThreadLocal in Java
Java Program to Implement Efficient O(log n) Fibonacci generator
Hướng dẫn tạo và sử dụng ThreadPool trong Java
Spring Boot - Eureka Server
Java Program to Implement the Alexander Bogomolny’s UnOrdered Permutation Algorithm for Elements Fro...
Shuffling Collections In Java
Creating a Generic Array in Java
Getting the Size of an Iterable in Java
The Java 8 Stream API Tutorial
Tìm hiểu về Web Service
Java Program to Evaluate an Expression using Stacks
How to Change the Default Port in Spring Boot