Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C/++/# Data compression with lissajous curve

  1. May 18, 2018 #1
    I was hoping this c++ file could be adapted to use as data compression or encryption

    Code (C):

    #include <iostream>
    #include <cmath>

    using namespace std;
    double asil(double t)
     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;

    double m=1,n=1,t=1,x=1,y=1;

    cout<<"enter x: " <<endl;
    cout<<"enter y: "<<endl;
    int i = 0;

        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))) ){

    else **/



    else if((sqrt(2)+tolerance)<=((asin(y)+2*pi*m)/(acos(x)+2*pi*n)))
    return 0;
    Last edited by a moderator: May 18, 2018
  2. jcsd
  3. May 18, 2018 #2


    User Avatar

    Staff: Mentor

    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?
  4. May 20, 2018 #3
    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
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?