Category: Geometric

Form a Rectangle from boundary elements of Matrix using Linked List

class Node:          def __init__(self, val):        self.data = val        self.next = None        self.prev = None        self.top = None        self.bottom = None    class LinkedList:          def __init__(self):        self.head = None              def Quad(self, grid, n, m):                  self.head = Node(grid[0][0])                  temp = self.head                  i = 0        j = 1                  while temp.top != self.head:                                                                                      if j < m and i == 0:                temp.next = Node(grid[i][j])                temp = temp.next                j += 1                                      elif j == m and i < n - 1:                i […]

Continue Reading

Program to calculate Surface Area of Ellipsoid

Given the length of the three semi-axes as A, B, and C, the task is to find the surface area of the given Ellipsoid.Ellipsoid is a closed surface of which all plane cross-sections are either ellipses or circles. An ellipsoid is symmetrical about the three mutually perpendicular axes that intersect at the center. It is […]

Continue Reading

Check if chords of a Circle are symmetric after some rotation

  #include using namespace std;  vector calculateDivisors(int N){    vector div;    for (int i = 1; i * i A[i].second) {            swap(A[i].first, A[i].second);        }        st.insert(A[i]);    }          vector div = calculateDivisors(N);          for (auto x : div) {        bool exist = 1;        for (int i = 0; i < M; i++) {            int dx = (A[i].first + x) % N;            int dy = (A[i].second + x) % N;            if (dx > dy) {                swap(dx, […]

Continue Reading

Check if N given lines can be intersected by K vertical lines

Given N horizontal lines represented by an array position[][] of size N, where position[i] represents the ith horizontal line which has x-coordinates from position[i][0] to position[i][1] and an integer K, which represents the maximum number of vertical lines that can be drawn, the task is to check if N given lines can be intersected by […]

Continue Reading

Maximum area of a Cake after Horizontal and Vertical cuts

Given two positive integers h and w representing the height h and width w which forms a rectangle. Also, there are two arrays of integers horizontalCuts and verticalCuts where horizontalCuts[i] is the distance from the top of the rectangle to the ith horizontal cut and similarly, verticalCuts[j] is the distance from the left of the […]

Continue Reading

Determine position of two points with respect to a 3D plane

#include using namespace std;  void check_position(int a, int b, int c, int d,                    int x1, int y1, int z1,                    int x2, int y2, int z2){        int value_1 = a * x1 + b * y1 + c * z1 + d;    int value_2 = a * x2 + b * y2 + c * z2 + d;          if ((value_1 > 0 […]

Continue Reading

Length of intercept cut off from a line by a Circle

#include using namespace std;  double radius(int a, int b, int c){            int g = a / 2;    int f = b / 2;          if (g * g + f * f – c < 0)        return (-1);          return (sqrt(g * g + f * f - c));}  double centerDistanceFromLine(int a, int b,                              int i, int j,                              int k){        int g = a / 2;    int f […]

Continue Reading