void BoneInstanceInfo::setObjectTolinear(UniversalObjectInterface *bObject, real t, UniversalObjectInterface *resultObject)
	{
		resultObject->setAngle(angle.angleLinear(bObject->getAngle(), t));
		resultObject->setPosition(linear(position, bObject->getPosition(), t));
		resultObject->setScale(linear(scale, bObject->getScale(), t));
		resultObject->setAlpha(linear(alpha, bObject->getAlpha(), t));
	}
Example #2
0
static int 
find_interval(PLFLT a0, PLFLT a1, PLINT c0, PLINT c1, PLFLT *x)
{
    register int n;

    n = 0;
    if (c0 == OK) {
	x[n++] = 0.0;
	n_point++;
    }
    if (c0 == c1)
	return n;

    if (c0 == NEG || c1 == POS) {
	if (c0 == NEG) {
	    x[n++] = linear(a0, a1, sh_min);
	    min_pts[min_points++] = n_point++;
	}
	if (c1 == POS) {
	    x[n++] = linear(a0, a1, sh_max);
	    max_pts[max_points++] = n_point++;
	}
    }
    if (c0 == POS || c1 == NEG) {
	if (c0 == POS) {
	    x[n++] = linear(a0, a1, sh_max);
	    max_pts[max_points++] = n_point++;
	}
	if (c1 == NEG) {
	    x[n++] = linear(a0, a1, sh_min);
	    min_pts[min_points++] = n_point++;
	}
    }
    return n;
}
	void EntityObjectInfo::setObjectTolinear(UniversalObjectInterface *bObject, real t, UniversalObjectInterface *resultObject)
	{
		resultObject->setAngle(angle.angleLinear(bObject->getAngle(), t));
		resultObject->setPosition(linear(position, bObject->getPosition(), t));
		resultObject->setScale(linear(scale, bObject->getScale(), t));
		resultObject->setAlpha(linear(alpha, bObject->getAlpha(), t));
		resultObject->setTimeRatio(linear(timeRatio, bObject->getTimeRatio(), t));
	}
Example #4
0
/* Returns complex valued linear interpolation. */
nr_complex_t interpolator::clinear (nr_double_t x, int idx) {
  nr_double_t x1, x2, r, i;
  nr_complex_t y1, y2;
  x1 = rx[idx]; x2 = rx[idx+1];
  y1 = cy[idx]; y2 = cy[idx+1];
  r = linear (x, x1, x2, real (y1), real (y2));
  i = linear (x, x1, x2, imag (y1), imag (y2));
  return nr_complex_t (r, i);
}
Example #5
0
void __pt_release_range(pte_t *pml4, virt_t from, virt_t to)
{
	DBG_ASSERT(linear(from) < linear(to));
	DBG_ASSERT(pml4 != 0);

	from = ALIGN_DOWN(linear(from), PAGE_SIZE);
	to = ALIGN(linear(to), PAGE_SIZE);

	pt_release_pml4(pml4, from, to);
}
Example #6
0
static __attribute__((const)) unsigned long join(unsigned long fg, unsigned long bg, unsigned long alpha)
{
  double t = (double)alpha * linear(fg) + (double)(255 - alpha) * linear(bg);
  t /= 255.;
  if (t <= 0.00304)
    t *= 12.92;
  else
    t = 1.055 * pow(t, 1.0 / 2.4) - 0.055;
  return (unsigned long)(255. * t + 0.5);
}
Example #7
0
inline Tv bilinear(
	const Tf& fracX, const Tf& fracY,
	const Tv& xy, const Tv& Xy,
	const Tv& xY, const Tv& XY
){
	return linear(fracY,
		linear(fracX, xy,Xy),
		linear(fracX, xY,XY)
	);
}
Example #8
0
void CLabel::paintWidget(int transparency, QPainter *device, int roundRadius)
{
	QPen pen(Qt::NoBrush, 1);
	device->setPen(pen);

	//QLinearGradient linear(this->rect().topLeft(), this->rect().topRight()); 
	//linear.setColorAt(0, QColor(24, 116, 205, transparency));  
	//linear.setColorAt(1, QColor(24, 116, 205, transparency/20));
	//linear.setColorAt(0, QColor(38, 184, 222, transparency)); 
	//linear.setColorAt(1, QColor(38, 184, 222,  transparency / 20));
	//linear.setColorAt(0, QColor(100, 149, 237, transparency));
	//linear.setColorAt(1, QColor(100, 149, 237, transparency / 20));
	//linear.setColorAt(0, QColor(96, 123, 139, transparency));
	//linear.setColorAt(1, QColor(96, 123, 139, 0));// transparency / 20));

	if (m_bEnableTransition)
	{
		QLinearGradient linear(this->rect().topLeft(), this->rect().topRight());
		linear.setColorAt(0, QColor(m_color.red(), m_color.green(), m_color.blue(), transparency));
		linear.setColorAt(1, QColor(m_color.red(), m_color.green(), m_color.blue(), 0));
		QBrush brush(linear);
		device->setBrush(brush);
		device->drawRoundedRect(this->rect(),roundRadius,roundRadius);
	}
	else if (!m_bIsBkgTransparent)
	{
		QLinearGradient linear(rect().topLeft(), rect().bottomLeft());
		
		if (roundRadius == 0)
		{
			linear.setColorAt(0, QColor(m_color.red(), m_color.green(), m_color.blue(), 10));
			linear.setColorAt(0.5, QColor(m_color.red(), m_color.green(), m_color.blue(), 20));
			linear.setColorAt(1, QColor(m_color.red(), m_color.green(), m_color.blue(), 10));
			QBrush brush(linear);
			device->setBrush(brush);
			device->drawRoundedRect(this->rect(), roundRadius, roundRadius);
		}
		else
		{
			QLinearGradient linear(this->rect().topLeft(), this->rect().bottomLeft());
			linear.setColorAt(0, QColor(m_color.red(), m_color.green(), m_color.blue(), transparency));
			QBrush brush(linear);
			device->setBrush(brush);
			device->drawRoundedRect(this->rect(), roundRadius, roundRadius);
		}
	} 
	else
	{
		QLinearGradient linear(this->rect().topLeft(), this->rect().bottomLeft());
		linear.setColorAt(0, QColor(m_color.red(), m_color.green(), m_color.blue(), transparency));
		QBrush brush(linear);
		device->setBrush(brush);
		device->drawRoundedRect(this->rect(), roundRadius, roundRadius);
	}
}
Example #9
0
Real SinTable<Real>::sin(Real x) const
{
    //Take arbitrary angle and bound between [0, pi*2)
    Real xn = Alge::mod(x, Real_::piTwo);
    if (xn < 0) xn = Real_::piTwo + xn;
    //Sin table uses symmetry and defines one quarter [0,pi/2].  Apply transform for other quarters.
    if (xn < Real_::pi)
        return xn < Real_::piHalf ? linear(_sin, xn*_radToSin) : linear(_sin, (Real_::pi-xn)*_radToSin);
    else
        return xn < Real_::piAndHalf ? -linear(_sin, (xn-Real_::pi)*_radToSin) : -linear(_sin, (Real_::piTwo-xn)*_radToSin);
}
Example #10
0
int __pt_populate_range(pte_t *pml4, virt_t from, virt_t to, pte_t flags)
{
	DBG_ASSERT(linear(from) < linear(to));
	DBG_ASSERT((flags & ~PTE_FLAGS) == 0);
	DBG_ASSERT(pml4 != 0);

	from = ALIGN_DOWN(linear(from), PAGE_SIZE);
	to = ALIGN(linear(to), PAGE_SIZE);

	return pt_populate_pml4(pml4, from, to, flags | PTE_PRESENT);
}
Example #11
0
float bilinear(const GridPointDataList * dl, double exactX, double exactY)
{
    // remove everything before comma (range now is [0,1))
    exactX -= (int) exactX;
    exactY -= (int) exactY;

    float tmp[2];
    tmp[0] = linear(dl->data[0].value, dl->data[1].value, exactX);
    tmp[1] = linear(dl->data[2].value, dl->data[3].value, exactX);
    float rd = linear(tmp[0], tmp[1], exactY);

    return rd;
}
Example #12
0
void kamikaze_update(struct actor_t* a, float dt)
{
	MADD(a->pos, a->pos, dt, a->vel);
	a->ang += a->aux[0]*dt;
	a->aux[0]*=1.1f;
	a->vel[2] = -20.0f*cosf(a->time+0.3f);
	if(a->pos[2] > 0.0f)
	{
		if(a->count++%3 == 0)
			for(int i = 0; i < 10; ++i)
			{
				vec3f vel;
				float ang = a->time + linear(-PI, PI, float(i)/10.0f);
				vel[0] = 20.0f*cosf(ang);
				vel[1] = 20.0f*sinf(ang);
				vel[2] = 0.0f;
				BULLET_shot(a->pos, vel, BULLET_ENEMY);
			}

		if(a->pos[2] > 6.0f)
		{
			EFFECTS_small_explosion();
			ACTOR_kill(a);
		}
	}
}
Example #13
0
std::pair<LatLonAlt,Velocity> KinematicsLatLon::turnOmega(std::pair<LatLonAlt,Velocity> sv0, double t, double omega) {
	if (Util::almost_equals(omega,0))
		return linear(sv0,t);
	LatLonAlt s0 = sv0.first;
	Velocity v0 = sv0.second;
	return turnOmega(s0,v0,t,omega);
}
Example #14
0
double Perceptron::solve(int opt,double d)
{
    double sum=0.0;


    for(unsigned int i=0;i<x.size();i++)
    {
        sum+=w[i]*x[i];
    }

    this->y=sum-theta;

    switch(opt)
    {
    case LINEARAF:
        this->O=linear(d,y);
        break;
    case STEPAF:
        this->O=step(d,y);
        break;
    case SIGMOIDAF:
        this->O=sigmoid(d,y);
        break;
    case SIGMOIDBIPAF:
        this->O=sigmoidBip(d,y);
        break;

    }

    return O;

}
Example #15
0
void boss_random_fire(struct actor_t* a, int n)
{
		random_ship_t* s = (random_ship_t*)a->child;
		int last = 0;
		for(int i = 0; i < s->w; ++i)
		{
			if(i == s->gun_first || i == s->gun_last)
			{
				vec3f p;
				SHIP_cell_pos(a, i, last, p);
				//BULLET_random_bullet(p,a->vel);
				for(int j = 0; j < n; ++j)
				{
					vec3f vel;
					float ang = -0.5f*PI - linear(-PI/2.0f, PI/2.0f, float(j)/float(n));
					vel[0] = 15.0f*cosf(ang);
					vel[1] = 15.0f*sinf(ang);
					vel[2] = 0.0f;
					BULLET_random_bullet(p,vel);
				}
				PART_damage(p, -0.2f);

			}
		}
}
Example #16
0
int main(void){
	linear();
	newton2();
	newton3();
	lagrange();
	return 0;
}
Example #17
0
Eigen::Matrix<T,4,1> blend(T t, Eigen::Matrix<T,4,1> p00, Eigen::Matrix<T,4,1> pNorm,
		   Eigen::Matrix<T,4,1> p10){
  T r0 = p00.mag();
  T r1 = p10.mag();
  T rs = linear(t,r0,r1);
  T dotp = dot(p00,p10);
  dotp = abs(dotp);
  T theta = acos(dotp/r0/r1);
  Eigen::Quaternion<T> dq0;
  p00.normalize();
  p10.normalize();
  Eigen::Quaternion<T> q00(p00);
  Eigen::Quaternion<T> q10(p10);	
  if (theta < 0.01) {
    //just give it a little nudge in the right direction
    T o = 0.10;
    Eigen::Quaternion<T> dq(cos(o/2.), sin(o/2.)*pNorm[0], sin(o/2.)*pNorm[1], sin(o/2.)*pNorm[2]);	
    Eigen::Matrix<T,4,1> p01 = dq.rotate(p00);
    Eigen::Quaternion<T> q01(p01);		
    dq0 = Eigen::Quaternion<T>::slerp(q01,q10,t);	
  } 
  else {
    dq0 = Eigen::Quaternion<T>::slerp(q00,q10,t);	
  }	
  T dott = p00.dot(p10);
  T dotq0 = q00.dot(q10);	
  T dotq1 = dq0.dot(q10);
  return Eigen::Matrix<T,4,1>(rs*dq0[1],rs*dq0[2],rs*dq0[3]);	
  //return Eigen::Matrix<T,4,1>(p01);
}
Example #18
0
 Y at_(double y, double x)  // wraps at south-west
 {
     assert(y >= 0);
     assert(x >= 0);
     size_t i = std::floor(y);
     size_t j = std::floor(x);
     Y nw = grid.cell(i, j);
     Y ne = (j == grid.w - 1) ? grid.cell(i, 0) : grid.cell(i, j + 1);
     Y sw = (i == grid.h - 1) ? grid.cell(0, j) : grid.cell(i + 1, j);
     Y se = (j == grid.w - 1 || i == grid.h - 1) ? grid.cell(0, 0)
             : grid.cell(i + 1, j + 1);
     return linear(
             linear(nw, ne, x - j),
             linear(sw, se, x - j),
             y - i);
 }
Example #19
0
void test_vector_magnitudes() {
    printf("Testing vector magnitudes...\n");
    TestStats stats = test_stats();
    Vector test_vector;
    double computed;

    test_vector = zeroes(0);
    computed = vector_mag(&test_vector);
    assert_double(&stats, 0, computed,
            "Zero element vectors should have zero magnitude");

    int i;
    for (i = -1; i < 3; i++) {
        test_vector = linear(1, i, 0);
        computed = vector_mag(&test_vector);
        assert_double(&stats, abs(i), computed, 
                "One element vectors must have magnitude equal to their element.");
    }

    double quad_a[4] = {-.4, 0, .6, 1.2};
    Vector quad = { 4, &quad_a[0] };
    computed = vector_mag(&quad);
    assert_double(&stats, 1.4, computed,
            "Incorrectly computed vector magnitude");

    print_state(&stats);
}
Example #20
0
// Test getting and setting easing properties via the metaobject system.
void tst_QEasingCurve::properties()
{
    tst_QEasingProperties obj;

    QEasingCurve inOutBack(QEasingCurve::InOutBack);
    qreal overshoot = 1.5;
    inOutBack.setOvershoot(overshoot);
    qreal amplitude = inOutBack.amplitude();
    qreal period = inOutBack.period();

    obj.setEasing(inOutBack);

    QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing"));
    QCOMPARE(easing.type(), QEasingCurve::InOutBack);
    QCOMPARE(easing.overshoot(), overshoot);
    QCOMPARE(easing.amplitude(), amplitude);
    QCOMPARE(easing.period(), period);

    QEasingCurve linear(QEasingCurve::Linear);
    overshoot = linear.overshoot();
    amplitude = linear.amplitude();
    period = linear.period();

    obj.setProperty("easing",
                    qVariantFromValue(QEasingCurve(QEasingCurve::Linear)));

    easing = qVariantValue<QEasingCurve>(obj.property("easing"));
    QCOMPARE(easing.type(), QEasingCurve::Linear);
    QCOMPARE(easing.overshoot(), overshoot);
    QCOMPARE(easing.amplitude(), amplitude);
    QCOMPARE(easing.period(), period);
}
Example #21
0
   // Given an edge, the constructor for EdgeRecord finds the
   // optimal point associated with the edge's current quadric,
   // and assigns this edge a cost based on how much quadric
   // error is observed at this optimal point.
   EdgeRecord::EdgeRecord( EdgeIter& _edge )
   : edge( _edge )
   {
      // TODO Compute the combined quadric from the edge endpoints.
			Matrix4x4 q = _edge->halfedge()->vertex()->quadric +
										_edge->halfedge()->twin()->vertex()->quadric;
		 
      // TODO Build the 3x3 linear system whose solution minimizes
      // the quadric error associated with these two endpoints.
			Matrix3x3 quadratic;
			quadratic(0,0) =  q(0,0); quadratic(0,1) =  q(0,1); quadratic(0,2) =  q(0,2);
			quadratic(1,0) =  q(1,0); quadratic(1,1) =  q(1,1); quadratic(1,2) =  q(1,2);
			quadratic(2,0) =  q(2,0); quadratic(2,1) =  q(2,1); quadratic(2,2) =  q(2,2);
			Vector3D linear(q(3,0), q(3,1), q(3,2));
		 
      // TODO Use this system to solve for the optimal position, and
      // TODO store it in EdgeRecord::optimalPoint.
			optimalPoint = - quadratic.inv() * linear;
		 
      // TODO Also store the cost associated with collapsing this edge
      // TODO in EdgeRecord::Cost.
			Vector4D optH(optimalPoint);
			optH.w = 1.0;
			score = dot(optH, q * optH);
   }
Example #22
0
STCalEnum::InterpolationType CalibrationManager::stringToInterpolationEnum(const string &s)
{
  String itype(s);
  itype.upcase();
  const Char *c = itype.c_str();
  String::size_type len = itype.size();
  Regex nearest("^NEAREST(NEIGHBOR)?$");
  Regex linear("^LINEAR$");
  Regex spline("^(C(UBIC)?)?SPLINE$");
  Regex poly("^POLY(NOMIAL)?$");
  if (nearest.match(c, len) != String::npos) {
    return STCalEnum::NearestInterpolation;
  }
  else if (linear.match(c, len) != String::npos) {
    return STCalEnum::LinearInterpolation;
  }
  else if (spline.match(c, len) != String::npos) {
    return STCalEnum::CubicSplineInterpolation;
  }
  else if (poly.match(c, len) != String::npos) {
    return STCalEnum::PolynomialInterpolation;
  }

  os_.origin(LogOrigin("CalibrationManager","stringToInterpolationEnum",WHERE));
  os_ << LogIO::WARN << "Interpolation type " << s << " is not available. Use default interpolation method." << LogIO::POST;
  return STCalEnum::DefaultInterpolation;
}
Example #23
0
int main(){
	int order;
	printf("Enter the order\n");
	scanf("%d",&order);
	linear(order);
	even_odd_switch(order);
	pascal(order);
}
	void IntVariableInfo::setToBlendedLinear(UniversalObjectInterface *aObject, UniversalObjectInterface *bObject, real t, real blendRatio, ObjectRefInstance *blendedRefInstance)
	{
		int tempValue = value;

		aObject->setObjectToLinear(bObject, t, this);

		setIntValue(linear(tempValue, value, blendRatio));
	}
Example #25
0
float Math::Interpolate::cosine(float a, float b, float t)
{
	// Cosine interpolation.
	float ft = t * Math::Constants::Pi;
	float f = (1 - Math::Cos(ft)) * 0.5f;

	// Linear interpolation.
	return linear(a, b, f);
}
Example #26
0
/*
 * geqo_selection
 *	 according to bias described by input parameters,
 *	 first and second genes are selected from the pool
 */
void
geqo_selection(Chromosome *momma, Chromosome *daddy, Pool *pool, double bias)
{
	int			first,
				second;

	first = linear(pool->size, bias);
	second = linear(pool->size, bias);

	if (pool->size > 1)
	{
		while (first == second)
			second = linear(pool->size, bias);
	}

	geqo_copy(momma, &pool->data[first], pool->string_length);
	geqo_copy(daddy, &pool->data[second], pool->string_length);
}
Example #27
0
void verify_rdft2(bench_problem *p, int rounds, double tol, errors *e)
{
     C *inA, *inB, *inC, *outA, *outB, *outC, *tmp;
     int n, vecn, N;
     dofft_rdft2_closure k;

     BENCH_ASSERT(p->kind == PROBLEM_REAL);

     if (!FINITE_RNK(p->sz->rnk) || !FINITE_RNK(p->vecsz->rnk))
	  return;      /* give up */

     k.k.apply = rdft2_apply;
     k.k.recopy_input = 0;
     k.p = p;

     if (rounds == 0)
	  rounds = 20;  /* default value */

     n = tensor_sz(p->sz);
     vecn = tensor_sz(p->vecsz);
     N = n * vecn;

     inA = (C *) bench_malloc(N * sizeof(C));
     inB = (C *) bench_malloc(N * sizeof(C));
     inC = (C *) bench_malloc(N * sizeof(C));
     outA = (C *) bench_malloc(N * sizeof(C));
     outB = (C *) bench_malloc(N * sizeof(C));
     outC = (C *) bench_malloc(N * sizeof(C));
     tmp = (C *) bench_malloc(N * sizeof(C));

     e->i = impulse(&k.k, n, vecn, inA, inB, inC, outA, outB, outC, 
		    tmp, rounds, tol);
     e->l = linear(&k.k, 1, N, inA, inB, inC, outA, outB, outC,
		   tmp, rounds, tol);

     e->s = 0.0;
     if (p->sign < 0)
	  e->s = dmax(e->s, tf_shift(&k.k, 1, p->sz, n, vecn, p->sign,
				     inA, inB, outA, outB, 
				     tmp, rounds, tol, TIME_SHIFT));
     else
	  e->s = dmax(e->s, tf_shift(&k.k, 1, p->sz, n, vecn, p->sign,
				     inA, inB, outA, outB, 
				     tmp, rounds, tol, FREQ_SHIFT));
     
     if (!p->in_place && !p->destroy_input)
	  preserves_input(&k.k, p->sign < 0 ? mkreal : mkhermitian1,
			  N, inA, inB, outB, rounds);

     bench_free(tmp);
     bench_free(outC);
     bench_free(outB);
     bench_free(outA);
     bench_free(inC);
     bench_free(inB);
     bench_free(inA);
}
Example #28
0
void WitnessSet::print_to_screen() const
{
	
	vec_mp dehom;  init_vec_mp(dehom,1); dehom->size = 1;
	
	std::stringstream varname;
	
	std::cout << "witness set has " << num_vars_ << " total variables, " << num_natty_vars_ << " natural variables." << std::endl;
	
	
	std::cout << "dim " << dim_ << ", comp " << comp_num_ << std::endl;
	std::cout << "input file name " << input_filename_ << std::endl;

	
	printf("******\n%zu points\n******\n",num_points());
	std::cout << color::green();
	for (unsigned ii=0; ii<num_points(); ii++) {
		
		dehomogenize(&dehom, point(ii), num_natty_vars_);
		
		varname << "point_" << ii;
		
		print_point_to_screen_matlab(dehom,varname.str());
		varname.str("");
	}
	std::cout << color::console_default();
	
	std::cout << color::blue();
	printf("******\n%zu linears\n******\n",num_linears());
	
	for (unsigned ii=0; ii<num_linears(); ii++) {
		varname << "linear_" << ii;
		print_point_to_screen_matlab(linear(ii),varname.str());
		varname.str("");
	}
	std::cout << color::console_default();
	
	std::cout << color::cyan();
	printf("******\n%zu patches\n******\n",num_patches());
	
	for (unsigned ii=0; ii<num_patches(); ii++) {
		varname << "patch_" << ii;
		print_point_to_screen_matlab(patch(ii),varname.str());
		varname.str("");
	}
	std::cout << color::console_default();
	
	std::cout << "variable names:\n";
	for (unsigned ii=0; ii< num_var_names(); ii++) {
		std::cout << name(ii) << "\n";
	}
	printf("\n\n");
	
	
	clear_vec_mp(dehom);
}
Example #29
0
std::pair<LatLonAlt,Velocity> KinematicsLatLon::turnUntilTimeRadius(const std::pair<LatLonAlt,Velocity>& svo, double t, double turnTime, double R, bool turnRight) {
	std::pair<LatLonAlt,Velocity> tPair;
	if (t <= turnTime) {
		tPair = turn(svo, t, R, turnRight);
	} else {
		tPair = turn(svo, turnTime, R, turnRight);
		tPair = linear(tPair,t-turnTime);
	}
	return tPair;
}
Example #30
0
/*
激活函数
*/
mat ActivateFunction(std::string ActivationFunction, mat x){
	if (ActivationFunction == "line" || ActivationFunction == "linear")
		return linear(x);
	else if(ActivationFunction == "tan" || ActivationFunction == "tanh")
		return tanh(x);
	else if(ActivationFunction == "rect" || ActivationFunction == "rectifier")
		return rectifier(x);
	else 
		return sigmoid(x);
}