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:
Validate email address exists or not by Java Code
Java Program to Print only Odd Numbered Levels of a Tree
Java Program to Implement Euclid GCD Algorithm
Lập trình đa luồng với CompletableFuture trong Java 8
Collect a Java Stream to an Immutable Collection
Injecting Prototype Beans into a Singleton Instance in Spring
Spring Boot - Enabling HTTPS
Netflix Archaius with Various Database Configurations
Comparing Long Values in Java
Introduction to Spring Data JPA
How to Change the Default Port in Spring Boot
Testing in Spring Boot
Read an Outlook MSG file
Java Program to Implement Fenwick Tree
Remove HTML tags from a file to extract only the TEXT
Examine the internal DNS cache
New Features in Java 9
Java Program to Check Whether Topological Sorting can be Performed in a Graph
Tránh lỗi ConcurrentModificationException trong Java như thế nào?
Spring Cloud – Securing Services
Guide to Apache Commons CircularFifoQueue
Number Formatting in Java
Use Liquibase to Safely Evolve Your Database Schema
Default Password Encoder in Spring Security 5
A Guide to the ResourceBundle
Spring Security Login Page with React
Java Program to Implement ArrayDeque API
Hướng dẫn sử dụng Lớp FilePermission trong java
Build a REST API with Spring and Java Config
Predicate trong Java 8
Java Program to Perform Searching Based on Locality of Reference
Hướng dẫn Java Design Pattern – MVC