কম্পিউটার টিউটোরিয়াল

C++-এ লাইন ও পয়েন্টের ডুয়ালিটি ট্রান্সফরমেশন (Duality Transformation)


এটি লাইন (Line) এবং পয়েন্ট (Point)-এর ডুয়ালিটি ট্রান্সফরমেশন (Duality Transformation) দেখানোর C++ প্রোগ্রাম। এর দুটি কেস থাকতে পারে:

কেস-১: একটি পয়েন্ট (a, b) লাইন (y = ax - b) এ ট্রান্সফর্ম হয়।

কেস-২: একটি লাইন D(y = cx + d) পয়েন্ট D'(c, -d) এ ট্রান্সফর্ম হয়।

ফাংশন ও সিউডোকোড

Function LineTransformation(double c, double d)

Print C: (d / c) D: (d * -1)

Function PointTransformation(double x, double y)

Print a = (-1 * y / x) b = (-1 * y)

উদাহরণ

#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;

void LineTransformation(double c, double d) {
    cout << "C: " << (d / c) << ", D: " << (d * -1);
}

void PointTransformation(double x, double y) {
    cout << "y=" << (-1 * y / x) << "x +" << (-1 * y);
}

int main(int argc, char **argv) {
    cout << "\n1. Line Transformation\n2. Point Transformation";
    int c;
    cin >> c;
    switch (c) {
        case 1:
            cout << "Enter the coefficients of line y=ax-b:";
            double a, b;
            cin >> a >> b;
            LineTransformation(a, b);
            break;
        case 2:
            cout << "Enter the coordinate of point ";
            double x, y;
            cin >> x >> y;
            PointTransformation(x, y);
            break;
        default:
            break;
    }
}

আউটপুট

1. Line Transformation
2. Point Transformation
1
Enter the coefficients of line y=ax-b: 1 2
C: 2, D: -2

1. Line Transformation
2. Point Transformation
2
Enter the coordinate of point  1 2
y=-2x +-2
  1. C++ দিয়ে লাইনের এক ছোরা এবং মিডপয়েন্ট দিয়ে অন্য ছোরা বের করা

  2. C++-এ সর্টেড বাইনারি অ্যারেতে ট্রানজিশন পয়েন্ট বের করা

  3. সি++-এ একটি রেখার মিড-পয়েন্ট বের করার প্রোগ্রাম

  4. সি++ প্রোগ্রাম: sin(x) এবং cos(x) এর মান গণনা করা