Skip to content

Commit

Permalink
Conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Nov 27, 2016
1 parent 4f6374e commit 3c6ac70
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/Mod/Sketcher/App/planegcs/Geo.cpp
Expand Up @@ -23,10 +23,12 @@

#define DEBUG_DERIVS 0
#if DEBUG_DERIVS
#include <cassert>
#endif

#include "Geo.h"

#include <cassert>

namespace GCS{

DeriVector2::DeriVector2(const Point &p, double *derivparam)
Expand Down Expand Up @@ -87,7 +89,15 @@ DeriVector2 DeriVector2::divD(double val, double dval) const
);
}

DeriVector2 Line::CalculateNormal(Point & /*p*/, double* derivparam)
DeriVector2 Curve::Value(double u, double du, double* derivparam)
{
assert(false /*Value() is not implemented*/);
return DeriVector2();
}

//----------------Line

DeriVector2 Line::CalculateNormal(Point &p, double* derivparam)
{
DeriVector2 p1v(p1, derivparam);
DeriVector2 p2v(p2, derivparam);
Expand Down Expand Up @@ -348,6 +358,39 @@ DeriVector2 Hyperbola::CalculateNormal(Point &p, double* derivparam)
return ret;
}

DeriVector2 Hyperbola::Value(double u, double du, double* derivparam)
{

//In local coordinate system, value() of hyperbola is:
//(a*cosh(u), b*sinh(u))
//In global, it is (vector formula):
//center + a_vec*cosh(u) + b_vec*sinh(u).
//That's what is being computed here.

// <construct a_vec, b_vec>
DeriVector2 c(this->center, derivparam);
DeriVector2 f1(this->focus1, derivparam);

DeriVector2 emaj = f1.subtr(c).getNormalized();
DeriVector2 emin = emaj.rotate90ccw();
double b, db;
b = *(this->radmin); db = this->radmin==derivparam ? 1.0 : 0.0;
double a, da;
a = this->getRadMaj(c,f1,b,db,da);
DeriVector2 a_vec = emaj.multD(a,da);
DeriVector2 b_vec = emin.multD(b,db);
// </construct a_vec, b_vec>

// sinh, cosh with derivatives:
double co, dco, si, dsi;
co = std::cosh(u); dco = std::sinh(u)*du;
si = std::sinh(u); dsi = std::cosh(u)*du;

DeriVector2 ret; //point of hyperbola at parameter value of u, in global coordinates
ret = a_vec.multD(co,dco).sum(b_vec.multD(si,dsi)).sum(c);
return ret;
}

int Hyperbola::PushOwnParams(VEC_pD &pvec)
{
int cnt=0;
Expand Down
10 changes: 10 additions & 0 deletions src/Mod/Sketcher/App/planegcs/Geo.h
Expand Up @@ -99,6 +99,15 @@ namespace GCS
// fields of DeriVector2.
virtual DeriVector2 CalculateNormal(Point &p, double* derivparam = 0) = 0;

/**
* @brief Value: returns point (vector) given the value of parameter
* @param u: value of parameter
* @param du: derivative of parameter by derivparam
* @param derivparam: pointer to sketch parameter to calculate the derivative for
* @return
*/
virtual DeriVector2 Value(double u, double du, double* derivparam = 0);

//adds curve's parameters to pvec (used by constraints)
virtual int PushOwnParams(VEC_pD &pvec) = 0;
//recunstruct curve's parameters reading them from pvec starting from index cnt.
Expand Down Expand Up @@ -206,6 +215,7 @@ namespace GCS
virtual double getRadMaj(double* derivparam, double &ret_dRadMaj);
virtual double getRadMaj();
DeriVector2 CalculateNormal(Point &p, double* derivparam = 0);
virtual DeriVector2 Value(double u, double du, double* derivparam = 0);
virtual int PushOwnParams(VEC_pD &pvec);
virtual void ReconstructOnNewPvec (VEC_pD &pvec, int &cnt);
virtual Hyperbola* Copy();
Expand Down

0 comments on commit 3c6ac70

Please sign in to comment.