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:
Quick Guide to Spring MVC with Velocity
Spring Boot - Sending Email
Java Program to Implement Graham Scan Algorithm to Find the Convex Hull
Java Program to Perform Searching Based on Locality of Reference
REST Pagination in Spring
Java Byte Array to InputStream
Java Program to Perform Searching Using Self-Organizing Lists
Introduction to Eclipse Collections
Java Timer
Java – Byte Array to Reader
Spring Boot - Admin Client
A Guide to Concurrent Queues in Java
Java Program to Search for an Element in a Binary Search Tree
Guide to WeakHashMap in Java
Lớp Properties trong java
Apache Camel with Spring Boot
Java Program to Test Using DFS Whether a Directed Graph is Strongly Connected or Not
Java Program to Implement the Monoalphabetic Cypher
Calling Stored Procedures from Spring Data JPA Repositories
A Guide to Iterator in Java
Java Program to find the maximum subarray sum O(n^2) time(naive method)
Java Program to Implement Best-First Search
Examine the internal DNS cache
Jackson Unmarshalling JSON with Unknown Properties
Introduction to Spring Data REST
Java toString() Method
Spring Boot - OAuth2 with JWT
Spring REST API + OAuth2 + Angular
Java Program to Implement Quick sort
Java Program to Check whether Directed Graph is Connected using DFS
Tính đa hình (Polymorphism) trong Java
Java Program to Represent Graph Using Linked List