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:
Request a Delivery / Read Receipt in Javamail
Java 14 Record Keyword
OAuth2.0 and Dynamic Client Registration
Java Program to Implement Find all Cross Edges in a Graph
Spring MVC and the @ModelAttribute Annotation
Java Program to Find MST (Minimum Spanning Tree) using Prim’s Algorithm
Java String Conversions
Spring Boot - File Handling
Giới thiệu JDBC Connection Pool
Java Program to Implement Suffix Tree
Spring Boot - Build Systems
Java Program to Find kth Largest Element in a Sequence
Spring MVC Custom Validation
HttpClient Basic Authentication
Tạo ứng dụng Java RESTful Client với thư viện Retrofit
Java Program to Implement SimpeBindings API
Java Program to Implement Bloom Filter
Một số nguyên tắc, định luật trong lập trình
An Intro to Spring Cloud Zookeeper
A Guide to Iterator in Java
LinkedList trong java
Mapping a Dynamic JSON Object with Jackson
REST Web service: Basic Authentication trong Jersey 2.x
Hướng dẫn Java Design Pattern – Composite
HttpClient 4 – Send Custom Cookie
Convert XML to JSON Using Jackson
Java Program to Implement Stack
A Guide to JUnit 5
Java Program to Find a Good Feedback Vertex Set
Java Program to Implement Bresenham Line Algorithm
Java Program to Create the Prufer Code for a Tree
The DAO with Spring and Hibernate