How to Homogenize a Point in Java?


In this article we will see how to homogenize a point. Any point in the projective plane is represented by a triple (X, Y, Z), called homogeneous coordinates or projective coordinates of the point, where X, Y and Z are not all 0. The point represented by a given set of homogeneous coordinates is unchanged if the coordinates are multiplied by a common factor.

As per the problem statement we have to homogenize a point by taking any common factor and multiplying it with the given points.

Let’s start!

To show you some instances

Instance-1

Suppose the points are (10, 20, 25)

Then the common factor of the points are 5, 10.

Suppose we take the greatest common factor i.e., 10 to homogenize the given points.

Then after homogenizing the point, result will be −

The homogeneous points are: (100, 200, 250)

Instance-2

Suppose the points are (8, 16, 12)

Then the common factors of the points are 2, 4.

Suppose we take the greatest common factor i.e., 4 to homogenize the given points.

Then after homogenizing the point, result will be

The homogeneous points are: (32, 64, 48)

Instance-3

Suppose the points are (12, 16, 20)

Then the common factors of the points are 2, 4.

Suppose we take the greatest common factor i.e., 4 to homogenize the given points.

Then after homogenizing the point, result will be

The homogeneous points are: (48, 64, 80)

Algorithm

Step 1 − Declare and initialise the variables.

Step 2 − Declare the common factor.

Step 3 − Declare the points.

Step 4 − Find the homogeneous points by multiplying the common factor.

Step 5 − Print the result.

Multiple Approaches

We have provided the solution in different approaches.

  • By Using Static Input

  • By Using User Defined Method

Let’s see the program along with its output one by one.

Approach-1: By Using Static Input

In this approach, we will declare the points, and common factor and then we will find homogeneous points by multiplying the common factor.

Example

public class Main{
   
   //main method
   public static void main(String[] args){

      //initialising the variables
      int x, y, z;
      
      //declaring the common factor
      int a = 10;

      //declaring the points
      int a1 = 10, a2 = 20, a3 = 25;
      
      //finding the homogeneous points
      x = a * a1;
      y = a * a2;
      z = a * a3;
      
      //print the result
      System.out.println("Homogeneous points: (" + x + ", " + y + ", " + z + ")");
   }
}

Output

Homogeneous points: (100, 200, 250)

Approach-2: By Using User Defined Method

In this approach, we will declare the points, and common factor and then we will find homogeneous points by multiplying the common factor using a user-defined method.

Example

public class Main{
   
   //main method
   public static void main(String[] args){

      //declaring the points
      int a1 = 8, a2 = 16, a3 = 12;

      //calling user defined method
      func(a1, a2, a3);
   }

   //user defined method
   static void func(int a1, int a2, int a3){

      //initialising the variables
      int x, y, z;
      //declaring the commom factor
      int a = 4;

      //finding the homogeneous points
      x = a * a1;
      y = a * a2;
      z = a * a3;

      //print the result
      System.out.println("Homogeneous points: (" + x + ", " + y + ", " + z + ")");
   }
}

Output

Homogeneous points: (32, 64, 48)

In this article, we explored how to homogenize a point by using Java programming language.

Updated on: 09-Mar-2023

111 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements