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:
Sử dụng CountDownLatch trong Java
LinkedHashSet trong Java hoạt động như thế nào?
Java Program to Solve Travelling Salesman Problem for Unweighted Graph
Recommended Package Structure of a Spring Boot Project
Lập trình hướng đối tượng (OOPs) trong java
Java Program to Implement the Program Used in grep/egrep/fgrep
Creating a Web Application with Spring 5
Apache Camel with Spring Boot
Java Concurrency Interview Questions and Answers
Introduction to Liquibase Rollback
Java Program to Implement Gauss Jordan Elimination
Java Program to Perform Right Rotation on a Binary Search Tree
REST Web service: Upload và Download file với Jersey 2.x
Java – Generate Random String
Java Program to Decode a Message Encoded Using Playfair Cipher
Java Program to Implement AA Tree
Daemon Threads in Java
Use Liquibase to Safely Evolve Your Database Schema
Converting String to Stream of chars
Java Program to Implement Fermat Primality Test Algorithm
Guide to Character Encoding
Lớp HashMap trong Java
Spring WebFlux Filters
Batch Processing with Spring Cloud Data Flow
Java Program to Implement HashMap API
Disable Spring Data Auto Configuration
Fixing 401s with CORS Preflights and Spring Security
Handling URL Encoded Form Data in Spring REST
Java Program to Find the Number of Ways to Write a Number as the Sum of Numbers Smaller than Itself
Multi Dimensional ArrayList in Java
HttpClient Connection Management
Concrete Class in Java