Example #1
0
 virtual const std::string do_type() const throw ()
 {
     //
     // A real application should use OS facilities for this.  This
     // is a crude hack.
     //
     using std::find;
     using std::string;
     using boost::algorithm::iequals;
     using boost::next;
     string media_type = "application/octet-stream";
     const string::const_reverse_iterator dot_pos =
         find(this->url_.rbegin(), this->url_.rend(), '.');
     if (dot_pos == this->url_.rend()
             || next(dot_pos.base()) == this->url_.end()) {
         return media_type;
     }
     const string::const_iterator hash_pos =
         find(next(dot_pos.base()), this->url_.end(), '#');
     const string ext(dot_pos.base(), hash_pos);
     if (iequals(ext, "wrl")) {
         media_type = "model/vrml";
     } else if (iequals(ext, "x3dv")) {
         media_type = "model/x3d+vrml";
     } else if (iequals(ext, "png")) {
         media_type = "image/png";
     } else if (iequals(ext, "jpg") || iequals(ext, "jpeg")) {
         media_type = "image/jpeg";
     }
     return media_type;
 }
Example #2
0
    std::tuple<bool, vector<char>> addTwoVectors(vector<char> base,
    vector<char> visitor) {
        // TODO(alex): change these reverses
        reverse(base.begin(), base.end());
        reverse(visitor.begin(), visitor.end());

        while (base.size() < visitor.size())
            base.push_back('0');
        while (visitor.size() < base.size())
            visitor.push_back('0');

        reverse(base.begin(), base.end());
        reverse(visitor.begin(), visitor.end());

        bool carry = 0;
        for (int i = 0; i < base.size(); i++) {
            base[i] += visitor[i] + carry - '0';
            if (base[i] > '9') {
                carry = 1;
                base[i] -= '9';
            } else {
                carry = 0;
            }
        }

        return make_tuple(carry, base);
    }
Example #3
0
int main(int argc, char **argv)
{
    setlocale(0, "Russian");
    ifstream In = ifstream("input.txt");

    if(!In.is_open())
    {
        printf_s("Нет файла :(\n");
        return -1;
    }

    Sphere s1 = ReadSphere(In);
    Sphere s2 = ReadSphere(In);

    In.close();

    PrintSphere(s1,1);
    PrintSphere(s2,2);

    ofstream Out = ofstream("output.txt");
    if(IsSphereContect(s1,s2))
    {
        Out<<"YES";
        printf("Сферы пересикаются\n");
    } else {
        Out<<"NO";
        printf("Сферы не пересикаются\n");
    }

    Out.close();
    return EXIT_SUCCESS;
}
Example #4
0
void DutchFlagPartition1(int pivot_index, vector<int>* A) {
    auto& A_ref = *A;
    int pivot = A_ref[pivot_index];

    cout << "pivot = " << pivot << endl;
    /**
      * keep the following invariants during partitioning:
      * bottom group: A_ref[0 : smaller - 1].
      * middle group: A_ref[smaller : equal - 1].
      * unclassified group: A_ref[equal : larger].
      * top group: A_ref[larger + 1 : A-ref.size() - 1].
      */

    int smaller = 0, equal = 0, larger = A_ref.size() - 1;
    // when there is any unclassified element.
    while (equal <= larger) {
        // A_ref[equal] is the incoming unclassified element.
        if (A_ref[equal] < pivot) {
            swap(A_ref[smaller++], A_ref[equal++]);
        } else
        if (A_ref[equal] == pivot) {
            ++equal;
        } else { // A_ref[equal] > pivot.
            swap(A_ref[equal], A_ref[larger--]);
        }
    }
}
vector<vector<FeatureTemplate>> CharacterFeatureGenerator::generateFeatureTemplates(const vector<CharWithSpace> &observationList) const {
    vector<vector<FeatureTemplate>> featureTemplateListList(observationList.size());
    for (size_t pos = 0; pos < observationList.size(); ++pos) {
        int startPos = max(0, (int)pos - (int)maxWindow);
        size_t endPos = min(observationList.size(), pos + maxWindow);
        assert(startPos >= 0);

        for (size_t curPos = startPos; curPos <= pos; ++curPos) {
            size_t maxN = min(endPos - curPos, maxNgram);
            int curPosOffset = curPos - pos + (curPos >= pos ? 1 : 0);

            stringstream prefix;
            prefix << "C" << showpos << curPosOffset << "/";
            for (size_t n = 1; n <= maxN; ++n) {
                if (curPos + n < pos || curPos > pos) {
                    continue;
                }
                string obs(prefix.str());
                for (size_t offset = 0; offset < n; ++offset) {
                    obs += observationList[curPos + offset].getCharacterCluster().toString();
                }
                size_t maxLen = min(maxLabelLength, pos - curPos + 1);
                for (size_t labelLength = 1; labelLength <= maxLen; ++labelLength) {
                    featureTemplateListList[pos].emplace_back(obs, labelLength);
                }
            }
        }
    }
    return featureTemplateListList;
}
Example #6
0
void TrainingSet::pushBack(const vector<string>& x) throw (invalid_argument) {
	if (x.size() != columns_)
		throw invalid_argument("Inserted row must have the same size as already existed rows.");
	if (x[categoryIndex_] == missingValueMark_)
		throw invalid_argument("Category column could not have missing values.");
	examples_.push_back(x);
}
Example #7
0
int qselect( int lo, int hi, int kth ) {

    while ( lo < hi ) {

        int i = lo;
        int j = hi - 1;
        while ( i <= j ) {
            while ( compare( order[i], order[hi] ) ) i++;
            while ( compare( order[hi], order[j] ) ) j--;
            if ( i <= j ) {
                swap( order[i], order[j] );
                i++; j--;
            }
        }

        j++;
        swap( order[j], order[hi] );
        if ( j == kth ) break;
        if ( j > kth )
             hi = j - 1;
        else lo = j + 1;
    }

    return order[kth];
}
Example #8
0
	basic_block& operator = (basic_block&& temp)
	noexcept {
		using std::swap;
		swap(_addr, temp._addr);
		swap(_size, temp._size);
		return *this;
	}
Example #9
0
int main(int, char**) {
  // bar has a non-trivial data member f, thus, we have to told
  // announce how to serialize/deserialize this member;
  // this is was the compound_member function is for;
  // it takes a pointer to the non-trivial member as first argument
  // followed by all "sub-members" either as member pointer or
  // { getter, setter } pair
  auto meta_bar_f = [] {
    return compound_member(&bar::f,
                           make_pair(&foo::a, &foo::set_a),
                           make_pair(&foo::b, &foo::set_b));
  };
  // with meta_bar_f, we can now announce bar
  announce<bar>("bar", meta_bar_f(), &bar::i);
  // baz has non-trivial data members with getter/setter pair
  // and getter returning a mutable reference
  announce<baz>("baz", compound_member(make_pair(&baz::f, &baz::set_f),
                                       make_pair(&foo::a, &foo::set_a),
                                       make_pair(&foo::b, &foo::set_b)),
                // compound member that has a compound member
                compound_member(&baz::b, meta_bar_f(), &bar::i));
  // spawn a testee that receives two messages
  auto t = spawn(testee, size_t{2});
  {
    scoped_actor self;
    self->send(t, bar{foo{1, 2}, 3});
    self->send(t, baz{foo{1, 2}, bar{foo{3, 4}, 5}});
  }
  await_all_actors_done();
  shutdown();
  return 0;
}
Example #10
0
static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, const SkDLine& line,
                       bool& flipped) {
    int result;
    flipped = false;
    if (line[0].fX == line[1].fX) {
        double top = line[0].fY;
        double bottom = line[1].fY;
        flipped = top > bottom;
        if (flipped) {
            using std::swap;
            swap(top, bottom);
        }
        result = intersections.vertical(quad, top, bottom, line[0].fX, flipped);
    } else if (line[0].fY == line[1].fY) {
        double left = line[0].fX;
        double right = line[1].fX;
        flipped = left > right;
        if (flipped) {
            using std::swap;
            swap(left, right);
        }
        result = intersections.horizontal(quad, left, right, line[0].fY, flipped);
    } else {
        intersections.intersect(quad, line);
        result = intersections.used();
    }
    return result;
}
Example #11
0
Screen* HighScoresScreen::processEvents(bool& quit)
{
	SDL_Event event;
	while(SDL_PollEvent(&event))
		if(event.type==SDL_KEYDOWN)
		{
			switch(event.key.keysym.sym)
			{
				case SDLK_DOWN:
					break;
				case SDLK_UP:
					break;
				case SDLK_RETURN:
					break;
				case SDLK_ESCAPE:
					try
					{
						return new MenuScreen(getSDLScreen());
					}
					catch(const exception& ex)
					{
						throw runtime_error(string("HighScoresScreen::processEvents(...): ")+ex.what());
					}
				default:
					return 0;
					break;
			}
		}
		else if(event.type==SDL_QUIT)
			quit=true;
	return 0;
}
void TConnectedClient::cleanup() {
  if (eventHandler_) {
    eventHandler_->deleteContext(opaqueContext_, inputProtocol_, outputProtocol_);
  }

  try {
    inputProtocol_->getTransport()->close();
  } catch (const TTransportException& ttx) {
    string errStr = string("TConnectedClient input close failed: ") + ttx.what();
    GlobalOutput(errStr.c_str());
  }

  try {
    outputProtocol_->getTransport()->close();
  } catch (const TTransportException& ttx) {
    string errStr = string("TConnectedClient output close failed: ") + ttx.what();
    GlobalOutput(errStr.c_str());
  }

  try {
    client_->close();
  } catch (const TTransportException& ttx) {
    string errStr = string("TConnectedClient client close failed: ") + ttx.what();
    GlobalOutput(errStr.c_str());
  }
}
Example #13
0
void test_constant()
{
    std::cout << "Testing that constants are interpolated correctly using barycentric interpolation on type " << boost::typeindex::type_id<Real>().pretty_name() << "\n";

    std::mt19937 gen(6);
    boost::random::uniform_real_distribution<Real> dis(0.1f, 1);
    std::vector<Real> x(100);
    std::vector<Real> y(100);
    Real constant = -8;
    x[0] = dis(gen);
    y[0] = constant;
    for (size_t i = 1; i < x.size(); ++i)
    {
        x[i] = x[i-1] + dis(gen);
        y[i] = y[0];
    }

    boost::math::barycentric_rational<Real> interpolator(x.data(), y.data(), y.size());

    for (size_t i = 0; i < x.size(); ++i)
    {
        // Don't evaluate the constant at x[i]; that's already tested in the interpolation condition test.
        Real t = x[i] + dis(gen);
        Real z = interpolator(t);
        BOOST_CHECK_CLOSE(z, constant, 100*sqrt(numeric_limits<Real>::epsilon()));
        BOOST_CHECK_SMALL(interpolator.prime(t), sqrt(numeric_limits<Real>::epsilon()));
    }
}
Example #14
0
void test_constant_high_order()
{
    std::cout << "Testing that constants are interpolated correctly in high order using barycentric interpolation on type " << boost::typeindex::type_id<Real>().pretty_name() << "\n";

    std::mt19937 gen(7);
    boost::random::uniform_real_distribution<Real> dis(0.1f, 1);
    std::vector<Real> x(100);
    std::vector<Real> y(100);
    Real constant = 5;
    x[0] = dis(gen);
    y[0] = constant;
    for (size_t i = 1; i < x.size(); ++i)
    {
        x[i] = x[i-1] + dis(gen);
        y[i] = y[0];
    }

    // Set interpolation order to 7:
    boost::math::barycentric_rational<Real> interpolator(x.data(), y.data(), y.size(), 7);

    for (size_t i = 0; i < x.size(); ++i)
    {
        Real t = x[i] + dis(gen);
        Real z = interpolator(t);
        BOOST_CHECK_CLOSE(z, constant, 1000*sqrt(numeric_limits<Real>::epsilon()));
        BOOST_CHECK_SMALL(interpolator.prime(t), 100*sqrt(numeric_limits<Real>::epsilon()));
    }
}
Example #15
0
void UiVariables::setScale(int newScale)
{
    if(newScale < 1)
        newScale = 1;

    if(scaleDial->value() != newScale)
    {
        int display_width = max( 1, getWidth() / scaleDial->value());

        int display_size = sizeDial->value() / scaleDial->value();
        display_size = max( 1, display_size);
        int newWidth = display_width * newScale;
        widthDial->setValue( newWidth);
        scaleDial->setValue(newScale);
        sizeDial->setMinimum(scaleDial->value() * 500);
        sizeDial->setValue(display_size*newScale);

        widthDial->setSingleStep(newScale);//increment the width step by scaleDial
        widthDial->setMinimum(newScale);
        widthDial->setMaximum(maxSaneWidth * newScale);
        oldScale = newScale;
        oldWidth = newWidth;
        emit internalsUpdated();
    }
}
Example #16
0
double CMT::MLR::evaluate(
	const pair<ArrayXXd, ArrayXXd>& data,
	const Preconditioner& preconditioner) const
{
	return -logLikelihood(preconditioner(data.first, data.second)).mean() / log(2.)
		- preconditioner.logJacobian(data).mean() / log(2.);
}
Example #17
0
pair<Timestamp, Timestamp> View::get_time_extents() const
{
	boost::optional<Timestamp> left_time, right_time;
	const set< shared_ptr<SignalData> > visible_data = get_visible_data();
	for (const shared_ptr<SignalData> d : visible_data) {
		const vector< shared_ptr<Segment> > segments =
			d->segments();
		for (const shared_ptr<Segment> &s : segments) {
			double samplerate = s->samplerate();
			samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;

			const Timestamp start_time = s->start_time();
			left_time = left_time ?
				min(*left_time, start_time) :
				                start_time;
			right_time = right_time ?
				max(*right_time, start_time + d->max_sample_count() / samplerate) :
				                 start_time + d->max_sample_count() / samplerate;
		}
	}

	if (!left_time || !right_time)
		return make_pair(0, 0);

	assert(*left_time < *right_time);
	return make_pair(*left_time, *right_time);
}
Example #18
0
SrtpSessionKeys* DtlsSocket::getSrtpSessionKeys() {
  // TODO(pedro): probably an exception candidate
  assert(mHandshakeCompleted);

  SrtpSessionKeys* keys = new SrtpSessionKeys();

  unsigned char material[SRTP_MASTER_KEY_LEN << 1];
  if (!SSL_export_keying_material(mSsl, material, sizeof(material), "EXTRACTOR-dtls_srtp", 19, NULL, 0, 0)) {
    return keys;
  }

  size_t offset = 0;

  memcpy(keys->clientMasterKey, &material[offset], SRTP_MASTER_KEY_KEY_LEN);
  offset += SRTP_MASTER_KEY_KEY_LEN;
  memcpy(keys->serverMasterKey, &material[offset], SRTP_MASTER_KEY_KEY_LEN);
  offset += SRTP_MASTER_KEY_KEY_LEN;
  memcpy(keys->clientMasterSalt, &material[offset], SRTP_MASTER_KEY_SALT_LEN);
  offset += SRTP_MASTER_KEY_SALT_LEN;
  memcpy(keys->serverMasterSalt, &material[offset], SRTP_MASTER_KEY_SALT_LEN);
  offset += SRTP_MASTER_KEY_SALT_LEN;
  keys->clientMasterKeyLen = SRTP_MASTER_KEY_KEY_LEN;
  keys->serverMasterKeyLen = SRTP_MASTER_KEY_KEY_LEN;
  keys->clientMasterSaltLen = SRTP_MASTER_KEY_SALT_LEN;
  keys->serverMasterSaltLen = SRTP_MASTER_KEY_SALT_LEN;

  return keys;
}
Example #19
0
int32_t mbl_mw_dataprocessor_threshold_create(MblMwDataSignal *source, MblMwThresholdMode mode, float boundary,
        float hysteresis, MblMwFnDataProcessor processor_created) {
    if (source->length() > PROCESSOR_MAX_LENGTH) {
        return MBL_MW_STATUS_ERROR_UNSUPPORTED_PROCESSOR;
    }

    MblMwDataProcessor *new_processor = new MblMwDataProcessor(*source);

    if (mode == MBL_MW_THRESHOLD_MODE_BINARY) {
        new_processor->is_signed = 1;
        new_processor->interpreter = DataInterpreter::INT32;
        new_processor->set_channel_attr(1, 1);
        new_processor->converter = FirmwareConverter::DEFAULT;
    }

    int32_t scaled_boundary= (int32_t) number_to_firmware_converters.at(source->converter)(source, boundary);
    uint16_t scaled_hysteresis= (uint16_t) number_to_firmware_converters.at(source->converter)(source, hysteresis);

    ThresholdConfig *config = (ThresholdConfig*) malloc(sizeof(ThresholdConfig));
    *((uint8_t*) config)= 0;
    config->length= source->length() - 1;
    config->is_signed= source->is_signed;
    config->mode= mode;
    memcpy(((uint8_t*)(config)) + 1, &scaled_boundary, sizeof(scaled_boundary));
    memcpy(((uint8_t*)(config)) + 5, &scaled_hysteresis, sizeof(scaled_hysteresis));

    create_processor(source, config, sizeof(ThresholdConfig), DataProcessorType::THRESHOLD, new_processor, processor_created);

    return MBL_MW_STATUS_OK;
}
Example #20
0
Resources JSONFormatter::parse( const Bytes& value )
{
    auto json = json::parse( String::to_string( value ) );
    
    if ( json.count( "data" ) == 0 )
    {
        throw domain_error( "Root property must be named 'data'." );
    }
    
    auto data = json[ "data" ];
    Resources resources;
    
    if ( data.is_array( ) )
    {
        for ( const auto object : data )
        {
            if ( not object.is_object( ) )
            {
                throw domain_error( "Root array child elements must be objects." );
            }
            
            resources.push_back( parse_object( object ) );
        }
    }
    else if ( data.is_object( ) )
    {
        resources.push_back( parse_object( data ) );
    }
    else
    {
        throw domain_error( "Root property must be unordered set or object." );
    }
    
    return resources;
}
TEST(prob_transform,cov_matrix_jacobian) {
  using stan::math::var;
  using stan::math::determinant;
  using std::log;
  using std::fabs;

  int K = 4;
  //unsigned int K = 4;
  unsigned int K_choose_2 = 6;
  Matrix<var,Dynamic,1> X(K_choose_2 + K);
  X << 1.0, 2.0, -3.0, 1.7, 9.8, 
    -12.2, 0.4, 0.2, 1.2, 2.7;
  std::vector<var> x;
  for (int i = 0; i < X.size(); ++i)
    x.push_back(X(i));
  var lp = 0.0;
  Matrix<var,Dynamic,Dynamic> Sigma = stan::math::cov_matrix_constrain(X,K,lp);
  std::vector<var> y;
  for (int m = 0; m < K; ++m)
    for (int n = 0; n <= m; ++n)
      y.push_back(Sigma(m,n));

  std::vector<std::vector<double> > j;
  stan::math::jacobian(y,x,j);

  Matrix<double,Dynamic,Dynamic> J(10,10);
  for (int m = 0; m < 10; ++m)
    for (int n = 0; n < 10; ++n)
      J(m,n) = j[m][n];

  double log_abs_jacobian_det = log(fabs(determinant(J)));
  EXPECT_FLOAT_EQ(log_abs_jacobian_det,lp.val());
}
Example #22
0
constexpr auto encode(Range&& range, OutputIterator out)
{
    using std::begin;
    using std::end;

    return encode(begin(range), end(range), out);
}
Example #23
0
    template <typename TimeSeries> double autocorrelation_time_from_binning(TimeSeries const &A) {
      using std::abs;
      auto size   = make_immutable_time_series(A).size();
      double var1 = abs(empirical_variance(make_immutable_time_series(A)));

      int B   = 2;
      auto Ab = make_binned_series(A, 2);

      using std::abs;
      auto t_cor = [&Ab](int bin_size, double var1) {
        double var = abs(empirical_variance(Ab));
        return .5 * (var / var1 * bin_size - 1);
      };

      double autocorr_time  = t_cor(B, var1);
      double slope          = 1.;
      int small_slope_count = 0;
      std::vector<double> t;
      while (small_slope_count < 5 && B < size / 10) {
        B *= 2;
        Ab               = make_binned_series(Ab, 2);
        double t_cor_new = t_cor(B, var1);
        slope            = (std::abs(t_cor_new - autocorr_time) / autocorr_time);
        if (slope < .5 * 1e-1) small_slope_count++;
        if (small_slope_count > 0) t.push_back(t_cor_new);
        autocorr_time = t_cor_new;
        //std::cout << B << "\t" << t_cor_new << "\t" << slope << std::endl;
      }
      if (t.size() > 0) {
        return abs(empirical_average(t));
      } else {
        TRIQS_RUNTIME_ERROR << "autocorrelation time not converged!!";
      }
    }
Example #24
0
auto decode(Range&& range, OutputIterator out)
{
    using std::begin;
    using std::end;

    return decode(begin(range), end(range), out);
}
 virtual void
 run (Arg)
   {
     ulong l1 (rand() % 1000);
     ulong l2 (rand() % 1000);
     string s1 (randStr(50));
     string s2 (randStr(50));
     const char* cp (s1.c_str());
     
     verifyWrapper<ulong> (l1, l2);
     verifyWrapper<ulong&> (l1, l2);
     verifyWrapper<ulong*> (&l1, &l2);
     verifyWrapper<ulong*> ((0), &l2);
     verifyWrapper<ulong*> (&l1, (0));
     verifyWrapper<ulong const&> (l1, l2);
     
     verifyWrapper<string> (s1, s2);
     verifyWrapper<string&> (s1, s2);
     verifyWrapper<string*> (&s1, &s2);
     
     verifyWrapper<const char*> (cp, "Lumiera");
     
     
     verifySaneInstanceHandling();
     verifySaneMoveHandling();
     verifyWrappedRef ();
     
     verifyFunctionResult ();
     verifyFunctionRefResult ();
   }
Example #26
0
Project1::Product::Product(const char *brand, const char *name,
                           const char *size)
{
    strcpy(this->brand,brand);
    strcpy(this->name,name);
    strcpy(this->size,size);
}
Example #27
0
 explicit BigNumber(string v) {
     int i = 0;
     if (v[i] == '-') {
         sign = 1;
         i++;
     }
     while (i < v.size()) {
         if (isdigit(v[i])) {
             integerPart.push_back(v[i]);
         } else {
             if (v[i] != '.')
                 throw std::runtime_error("NaN");
             break;
         }
         i++;
     }
     if (v[i] == '.') {
         i++;
         while (i < v.size()) {
             if (isdigit(v[i]))
                 fractionaryPart.push_back(v[i]);
             else
                 throw std::runtime_error("NaN");
             i++;
         }
     }
     reverse(integerPart.begin(), integerPart.end());
     if (fractionaryPart.size())
         reverse(fractionaryPart.begin(), fractionaryPart.end());
 }
Example #28
0
    bool __next_perm(vector<int>::iterator beg, vector<int>::iterator end) {
        if (beg == end) {
            return false;
        }

        vector<int>::iterator i = beg;
        ++i;
        if (i == end) {
            return false;
        }

        i = end;
        --i;

        for (;;) {
            vector<int>::iterator ii = i;
            --i;
            if (*i < *ii) {
                vector<int>::iterator j = end;
                while (!(*i < *--j));

                std::iter_swap(i, j);
                reverse(ii, end);
                return true;
            }

            if (i == beg) {
                reverse(beg, end);
                return false;
            }
        }
    }
 bool checkNearby(map<int, int> &mm, int num1, int diff) {
     auto it = mm.find(num1);
     if (it->second > 1) {
         return true;
     }
     
     int num2;
     if (it != mm.begin()) {
         --it;
         num2 = it->first;
         ++it;
         if (abs((int64_t)num1 - num2) <= diff) {
             return true;
         }
     }
     if (next(it) != mm.end()) {
         ++it;
         num2 = it->first;
         --it;
         if (abs((int64_t)num1 - num2) <= diff) {
             return true;
         }
     }
     
     return false;
 }
Example #30
0
double DirectionCanvas::translateMouseCoords(double trans_x, double trans_y)
{
	// We now have 4 squares. One four every corner.
	// With a cross in the middle.
	// For every square we calculate a different tangent
	// therefore we have to add of substract a number of degrees
	double result = 0;
	if (trans_x >= 0 && trans_y >= 0) {
		// Right down
		double arc_tan = trans_y / trans_x;
		result = 90 + (atan(arc_tan)) * (180/M_PI);
	} else if (trans_x <= 0 && trans_y >= 0) {
		// Left down
		trans_x = trans_x * -1;
		double arc_tan = trans_y / trans_x;
		result = 270 - (atan(arc_tan)) * (180/M_PI);
	} else if (trans_x >= 0 && trans_y <= 0) {
		// Right up
		trans_y = trans_y * -1;
		double arc_tan = trans_y / trans_x;
		result = 90 - (atan(arc_tan)) * (180/M_PI);
	} else if (trans_x <= 0 && trans_y <= 0) {
		// Left up
		trans_x = trans_x * -1;
		trans_y = trans_y * -1;
		double arc_tan = trans_y / trans_x;
		result = 270 + (atan(arc_tan)) * (180/M_PI);
	}
	return result;
}