Data compression with lissajous curve

In summary: So if you have a number like 123, it would become 0012 in the asil function.In summary, the code can be used for compression and encryption, but it is not clear how it works or what it is intended to do.
  • #1
benjamin p north
2
0
I was hoping this c++ file could be adapted to use as data compression or encryption
Code:
#include <iostream>
#include <cmath>

using namespace std;
double asil(double t)
{
    cout<<"asil\n";
 cout<< cos(t) << endl;
 double two = 2.0;
 cout<< sin(sqrt(two)*t) << endl; return sin(sqrt(two)*t);
}

int main(){
    double one = 1;
    double four = 4;
    double pi = atan(one)*four;
    double tolerance = .00001;
//cout<<"dedede";

double m=1,n=1,t=1,x=1,y=1;
cout<<"enter x: " <<endl;
cin>>x;
cout<<"enter y: "<<endl;
cin>>y;
int i = 0;
while(

(sqrt(2)-tolerance)>((asin(y)+2*pi*m)/(acos(x)+2*pi*n))||
(sqrt(2)+tolerance)<((asin(y)+2*pi*m)/(acos(x)+2*pi*n)))
{
    if(i++ % 100000 == 0) asil(t);
/**
if( ((sqrt(2)+0.0001)>=((asin(y)+2*pi*m)/(acos(x)+2*pi*n)))
&&((sqrt(2)-0.0001)<=((asin(y)+2*pi*m)/(acos(x)+2*pi*n))) ){ t=acos(x)+2*pi*n;
 cout<<t<<endl;
 }
else **/
 if(

(sqrt(2)-tolerance)>=((asin(y)+2*pi*m)/(acos(x)+2*pi*n))){
m=m+1;}

else if((sqrt(2)+tolerance)<=((asin(y)+2*pi*m)/(acos(x)+2*pi*n)))
{
n=n+1;}
}
 t=acos(x)+2*pi*n;
 cout<<t<<endl;
 asil(t);
return 0;
}
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
benjamin p north said:
I was hoping this c++ file could be adapted to use as data compression or encryption
Code:
#include <iostream>
#include <cmath>

using namespace std;
double asil(double t)
{
    cout<<"asil\n";
 cout<< cos(t) << endl;
 double two = 2.0;
 cout<< sin(sqrt(two)*t) << endl; return sin(sqrt(two)*t);
}

int main(){
    double one = 1;
    double four = 4;
    double pi = atan(one)*four;
    double tolerance = .00001;
//cout<<"dedede";

double m=1,n=1,t=1,x=1,y=1;
cout<<"enter x: " <<endl;
cin>>x;
cout<<"enter y: "<<endl;
cin>>y;
int i = 0;
while(

(sqrt(2)-tolerance)>((asin(y)+2*pi*m)/(acos(x)+2*pi*n))||
(sqrt(2)+tolerance)<((asin(y)+2*pi*m)/(acos(x)+2*pi*n)))
{
    if(i++ % 100000 == 0) asil(t);
/**
if( ((sqrt(2)+0.0001)>=((asin(y)+2*pi*m)/(acos(x)+2*pi*n)))
&&((sqrt(2)-0.0001)<=((asin(y)+2*pi*m)/(acos(x)+2*pi*n))) ){ t=acos(x)+2*pi*n;
 cout<<t<<endl;
 }
else **/
 if(

(sqrt(2)-tolerance)>=((asin(y)+2*pi*m)/(acos(x)+2*pi*n))){
m=m+1;}

else if((sqrt(2)+tolerance)<=((asin(y)+2*pi*m)/(acos(x)+2*pi*n)))
{
n=n+1;}
}
 t=acos(x)+2*pi*n;
 cout<<t<<endl;
 asil(t);
return 0;
}
Welcome to the PF.

I added code tags to your post -- please use code tags to improve readability of code posted here at the PF. Thanks.

Also, it's a lot of work trying to decode your uncommented code. Could you explain what you are trying to do? Could you post links to the reading that you have been doing that suggests this code can be used for encryption?
 
  • Like
Likes Greg Bernhardt
  • #3
berkeman said:
Welcome to the PF.

I added code tags to your post -- please use code tags to improve readability of code posted here at the PF. Thanks.

Also, it's a lot of work trying to decode your uncommented code. Could you explain what you are trying to do? Could you post links to the reading that you have been doing that suggests this code can be used for encryption?
I was trying to take two numbers between zero and one and compress them into one number in a way that you can use trig to get back the original two numbers.

Eg. X= cos t y=sin (sqrt2*t)
Plug in x and y. Then solve for t. You can use t later to get back x and y. Hopefully t is shorter to write than x and y.

I was also hoping it could be used for encryption.

Additionally, it's a reversible calculation. Unlike adding 2 plus 3 to get 5. Once you have 5, you can't tell if it came from 2 plus 3 or 1 plus 4.Also it's a 1 to 2 mapping
 

FAQ: Data compression with lissajous curve

What is data compression?

Data compression is the process of reducing the size of a file or data set by encoding it in a more efficient way, while still retaining the essential information.

How does data compression with lissajous curve work?

Data compression with lissajous curve is a mathematical technique that uses the properties of lissajous curves, which are complex patterns formed by two intersecting harmonic motions, to encode data. The data is broken down into smaller chunks and plotted on a lissajous curve, with the intersections representing the data points. This method is efficient because it uses the inherent properties of lissajous curves to represent the data in a concise manner.

What are the advantages of using lissajous curve for data compression?

One of the main advantages of using lissajous curve for data compression is its ability to compress data without losing any essential information. This method also has a high compression ratio, meaning that it can significantly reduce the size of the data while retaining its quality. Additionally, lissajous curve compression is relatively simple and fast compared to other compression techniques.

Are there any limitations or drawbacks to data compression with lissajous curve?

One potential limitation of using lissajous curve for data compression is that it is not as widely used or supported as other compression methods, so it may not be compatible with all systems or devices. Additionally, the compression ratio may not be as high for certain types of data, and the compression process may require a significant amount of computational power.

In what applications is data compression with lissajous curve commonly used?

Data compression with lissajous curve is commonly used in fields such as telecommunications, image and video processing, and data storage. It is also used in scientific and academic research for data analysis and data compression experiments.

Similar threads

Back
Top