Пример #1
0
bool ZernikeMom::CalculateOneFrame(int frame){
  const double PI = 3.141592654;

  // cout << "ZernikeMom::CalculateOneFrame("<<frame<<")"<<endl;

   EnsureImage();
   SegmentData()->setCurrentFrame(frame);
   
   TabulateFactorials(param.maxorder);

   FindSegmentNormalisations();
   
   int nc=NumberOfCoefficients(param.maxorder);

   vector<double> zerovec(nc,0.0);

   vector<vector<double> > A_real(DataCount(),zerovec);
   vector<vector<double> > A_imag(DataCount(),zerovec);

    int width = Width(true), height = Height(true);

    int resind=0;

    for(int n=0;n<=param.maxorder;n++)
      for(int m=n&1;m<=n;m+=2){
	for (int y=0; y<height; y++)
	  for (int x=0; x<width; x++){
	    vector<int> svec = SegmentVector(frame, x, y);
	    for (size_t j=0; j<svec.size(); j++) {
	      int dataind = DataIndex(svec[j], true);
	      if(dataind != -1){
		int label=svec[j];
		double xtilde=(x-XAvg(label))*Scaling(label);
		double ytilde=(y-YAvg(label))*Scaling(label);
		double roo=sqrt(xtilde*xtilde+ytilde*ytilde);
		double theta;
		if(ytilde || xtilde)
		  theta=atan2(ytilde,xtilde);
		else
		  theta=0;

		double r=R(n,m,roo);
		r *= Scaling(label)*Scaling(label)*(n+1)/PI;
		A_real[dataind][resind] += r*cos(m*theta);
		A_imag[dataind][resind] -= r*sin(m*theta);
	      }
	    }
	  }
	resind++;
      }

    for(size_t i=0;i<A_real.size();i++){
      ((ZernikeMomData*)GetData(i))->SetData(A_real[i],A_imag[i],param);
    }
    calculated = true;

    return true;
}
Пример #2
0
bool ZernikeMom::CalculateOneLabel(int frame, int label)
{
  const double PI = 3.141592654;

    EnsureImage();
    SegmentData()->setCurrentFrame(frame);

    TabulateFactorials(param.maxorder);

    FindSegmentNormalisations(label);

    int nc=NumberOfCoefficients(param.maxorder);

    vector<double> A_real(nc,0.0);
    vector<double> A_imag(nc,0.0);

    int width = Width(true), height = Height(true);

    int resind=0;

    for(int n=0;n<=param.maxorder;n++)
      for(int m=n&1;m<=n;m+=2){
	for (int y=0; y<height; y++)
	  for (int x=0; x<width; x++){
	    vector<int> svec = SegmentVector(frame, x, y);
	    for (size_t j=0; j<svec.size(); j++) {
	      if(svec[j]==label){
		double xtilde=(x-XAvg(label))*Scaling(label);
		double ytilde=(y-YAvg(label))*Scaling(label);
		double roo=sqrt(xtilde*xtilde+ytilde*ytilde);
		double theta;
		if(ytilde || xtilde)
		  theta=atan2(ytilde,xtilde);
		else
		  theta=0;
		double r=R(n,m,roo);
		r *= Scaling(label)*Scaling(label)*(n+1)/PI;
		A_real[resind] += r*cos(m*theta);
		A_imag[resind] -= r*sin(m*theta);
	      }
	    }
	  }
	resind++;
      }


    int ind = DataIndex(label, true);
    if(ind==-1) return false;

    ((ZernikeMomData*)GetData(ind))->SetData(A_real,A_imag,param);

    calculated = true;

    return true;
}
Пример #3
0
ITG cgsolver (double *A, double *x, double *b, ITG neq, ITG len, 
	       ITG *ia, ITG *iz, 
				double *eps, ITG *niter, ITG precFlg)
{
  ITG i=0;
  double *Factor=NULL,*r=NULL,*p=NULL,*z=NULL,*C=NULL,*g=NULL,*rho=NULL;

  /*  reduce row and column indices by 1 (FORTRAN->C)   */

  for (i=0; i<neq; i++)	--iz[i];
  for (i=0; i<len; i++)	--ia[i];

  /*  Scaling the equation system A x + b = 0  */

  Factor=NNEW(double,neq);
  Scaling(A,b,neq,ia,iz,Factor);

  /*  SOLVER/PRECONDITIONING TYPE  */

  /*  Conjugate gradient solver without preconditioning  */

  if (!precFlg)
    {
      r=NNEW(double,neq);
      p=NNEW(double,neq);
      z=NNEW(double,neq);
      CG(A,x,b,neq,len,ia,iz,eps,niter,r,p,z);
      free(r);free(p);free(z);
    }
Пример #4
0
    void applyVerticalHintingTransform (float fontSize, Path& path)
    {
        if (cachedSize != fontSize)
        {
            cachedSize = fontSize;
            cachedScale = Scaling (top, middle, bottom, fontSize);
        }

        if (bottom < top + 3.0f / fontSize)
            return;

        Path result;

        for (Path::Iterator i (path); i.next();)
        {
            switch (i.elementType)
            {
                case Path::Iterator::startNewSubPath:  result.startNewSubPath (i.x1, cachedScale.apply (i.y1)); break;
                case Path::Iterator::lineTo:           result.lineTo (i.x1, cachedScale.apply (i.y1)); break;
                case Path::Iterator::quadraticTo:      result.quadraticTo (i.x1, cachedScale.apply (i.y1),
                                                                           i.x2, cachedScale.apply (i.y2)); break;
                case Path::Iterator::cubicTo:          result.cubicTo (i.x1, cachedScale.apply (i.y1),
                                                                       i.x2, cachedScale.apply (i.y2),
                                                                       i.x3, cachedScale.apply (i.y3)); break;
                case Path::Iterator::closePath:        result.closeSubPath(); break;
                default:                               jassertfalse; break;
            }
        }

        result.swapWithPath (path);
    }
// Run a single benchmark for multiplying m x k x n with num_steps of recursion.
// To just call GEMM, set num_steps to zero.
// The median of five trials is printed to std::cout.
// If run_check is true, then it also
void SingleBenchmark(int m, int k, int n, int alg) {
  // Run a set number of trials and pick the median time.
  int num_trials = 5;
  std::vector<double> times(num_trials);
  for (int trial = 0; trial < kNumTrials; ++trial) {
    Matrix<double> A = RandomMatrix<double>(m, k);
    Matrix<double> B = RandomMatrix<double>(k, n);
    Matrix<double> C(m, n);
    if (alg == CLASSICAL) {
      times[trial] = Time([&] { MatMul(A, B, C); });
    } else if (alg == STRASSEN) {
      times[trial] = Time([&] { strassen::FastMatmul(A, B, C, 1); });
    } else if (alg == STRASSEN_SCALED) {
      times[trial] = Time([&] {
	  Matrix<double> A_roi = A;
	  Matrix<double> B_roi = B;
	  std::vector<double> r_roi, s_roi;
	  Scaling(A_roi, B_roi, kNumScalingSteps, r_roi, s_roi, OUTSIDE_INSIDE);
	  strassen::FastMatmul(A, B, C, 1);
	  PostProcessScaling(C, r_roi, s_roi);
	});
    }
  }

  // Spit out the median time
  std::sort(times.begin(), times.end());
  size_t ind = num_trials / 2;
  std::cout << " " << m << " " << k << " " << n << " "
            << " " << times[ind] << "; ";
}
Пример #6
0
	Matrix4x4 Matrix4x4::TRS(const Vector3 &t, const Quaternion &r, const Vector3 &s)
	{
		Matrix4x4 mt = Translation(t);
		Matrix4x4 mr = Rotation(r);
		Matrix4x4 ms = Scaling(s);

		return mt * mr * ms;
	}
Пример #7
0
void animateScene(int value) {
  glutTimerFunc(REFRESH_MILISECS, animateScene, 0);

  static float scale = 1.0f;
  VECTOR4D Speed = { 0.02f, 0.02f, 0.02f, 0.0f };
  //MATRIX4D P = PerspectiveWidthHeightRH(0.5f, 0.5f, 1.0f, 10.0f);
  MATRIX4D InvV = FastInverse(Vi);
  VECTOR4D XDir = { InvV.m00, InvV.m10, InvV.m20, 0.0f };
  VECTOR4D YDir = { InvV.m01, InvV.m11, InvV.m21, 0.0f };
  VECTOR4D ZDir = { InvV.m02, InvV.m12, InvV.m22, 0.0f };
  VECTOR4D EyePos = { InvV.m03, InvV.m13, InvV.m23, 1.0f };

  P = PerspectiveWidthHeightRH(0.5f, 0.5f, 1.0f, 10.0f);

  if (bLeft)
    EyePos = EyePos + XDir * Speed;
  if (bRight)
    EyePos = EyePos - XDir * Speed;
  if (bDown)
    EyePos = EyePos + YDir * Speed;
  if (bUp)
    EyePos = EyePos - YDir * Speed;
  if (bBackward)
    EyePos = EyePos + ZDir * Speed;
  if (bForward)
    EyePos = EyePos - ZDir * Speed;
  InvV.m03 = EyePos.x;
  InvV.m13 = EyePos.y;
  InvV.m23 = EyePos.z;
  Vi = FastInverse(InvV);

  if (bRotateX) {
	  //R = R * RotationX(INCREMENT);
	  VECTOR4D Axis = {1, 0, 0, 0};
	  R = R * RotationAxis(INCREMENT, Axis);
  }
  if (bRotateY) {
	  //R = R * RotationY(INCREMENT);
	  VECTOR4D Axis = { 0, 1, 0, 0 };
	  R = R * RotationAxis(INCREMENT, Axis);
  }
  if (bRotateZ) {
	  //R = R * RotationZ(INCREMENT);
	  VECTOR4D Axis = { 0, 0, 1, 0 };
	  R = R * RotationAxis(INCREMENT, Axis);
  }
  if (bScaleUp)
    scale += INCREMENT;
  if (bScaleDown)
    scale -= INCREMENT;

  T = (P * Vi) * R * Scaling(scale, scale, scale);

  glutPostRedisplay();
}
Пример #8
0
namespace CGAL {

const Translation             TRANSLATION = Translation();
const Rotation                ROTATION = Rotation();
const Scaling                 SCALING = Scaling();
const Reflection              REFLECTION = Reflection();
const Identity_transformation IDENTITY = Identity_transformation();

const Origin      ORIGIN = Origin();
const Null_vector NULL_VECTOR = Null_vector();

} //namespace CGAL
Пример #9
0
//===============================================
//処理
//===============================================
//[input]
//	なし
//[return]
//	なし
//===============================================
void CField::Exec()
{
	//::D3DXVec3TransformCoord(&vAxisX, &vAxisX, &m_matRotate);
	//::D3DXVec3TransformCoord(&vAxisZ, &vAxisZ, &m_matRotate);
	
	//if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_DIR_LEFT) )
	//{
	//	m_vPos -= vAxisX*0.1f;
	//	//m_Anim += 1.0f;
	//}
	//
	//if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_DIR_RIGHT) )
	//{
	//	m_vPos += vAxisX*0.1f;
	//	//m_Anim += 1.0f;
	//}	
	//
	//if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_DIR_UP) )
	//{
	//	m_vPos -= vAxisZ * 0.1f;
	//	//m_vPos.z -= 0.1f;
	//	//m_Anim += 1.0f;
	//}
	//
	//if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_DIR_DOWN) )
	//{
	//	m_vPos += vAxisZ * 0.1f;
	//	//m_vPos.z += 0.1f;
	//	//m_Anim += 1.0f;
	//}
	
	
	//if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_BUTTON_02) )
	//{
	//	m_vRot.x += 0.1f;
	//}
	
//	Update(0.000f);
	
	Translation(m_vPos.x, m_vPos.y, m_vPos.z);
	
	Scaling(m_vScale.x, m_vScale.y, m_vScale.z);
	
	Heading(m_vRot.x);
	
	Pitching(m_vRot.x);
	
	Rolling(m_vRot.x);
	
	Render(Joker::GetDevice());
	
	SetWorldMatrix();
}
Пример #10
0
static void
Prologue()
{
    if (eflag) {
	floatish epsfscale = epsfwidth / (floatish) borderwidth;
	EPSFSpecialComments(epsfscale);
	Scaling(epsfscale);
    } else {
	StandardSpecialComments();
	if (gflag) Portrait(); else Landscape();
    }
}
Пример #11
0
int main(){
	Macro();
	int n;for (scanf("%d", &n); n; n--) {
		char c;	Point_3 p;
		scanf("\n%c%lf%lf%lf", &c, &p.x, &p.y, &p.z);
		if (c == 'T') Translation(p);	if (c == 'S') Scaling(p);
		if (c == 'R') {	double r;scanf("%lf\n", &r);
			Rotate(p, r);	//===========绕OP逆时针旋转r角度
        }}
	for (scanf("%d", &n); n; n--) {
		Point_3 p, p2;	scanf("%lf%lf%lf", &p.x, &p.y, &p.z);
		p2 = opt(p); 	printf(“%f %f %f\n”,p2.x,p2.y,p2.z);
    }
}
Пример #12
0
void ros_kinfu_publisher::publishTSDFCloud(PointCloudTSDF::Ptr cloud_ptr){

    sensor_msgs::PointCloud2 msg;
    PointCloudTSDF::Ptr tsdf_output_ptr(new PointCloudTSDF);

    Affine3f scale;
    scale = Scaling(1/1000.f);

    pcl::transformPointCloud(*cloud_ptr,*tsdf_output_ptr,scale);
    pcl::toROSMsg(*tsdf_output_ptr,msg);
    msg.header.frame_id = kf_world_frame;
    msg.header.stamp = ros::Time::now();

    tsdfPublisher.publish(msg);

}
Пример #13
0
bool cTexture::draw
( 
	long p_destX, long p_destY, 
	long p_srcX /*= 0*/, long p_srcY /*= 0*/, 
	long p_width /*= 0*/, long p_height /*= 0*/, 
	D3DCOLOR p_color /*= 0xffffffff*/,
	D3DXVECTOR2 *p_pRotationCenter /*= NULL*/,
	float p_angle /*= 0.0f*/, 
	float p_XScale /*= 1.0f*/, float p_YScale /*= 1.0f*/
)
{
	RECT rect;
	ID3DXSprite *pSprite;
	
	if(m_pTexture == NULL)
		return FALSE;
	if(m_pGraphics == NULL)
		return FALSE;
	if((pSprite = m_pGraphics->getSprite()) == NULL)
		return FALSE;
	
	if(!p_width)
		p_width = m_width;
	if(!p_height)
		p_height = m_height;
	
	rect.left = p_srcX;
	rect.top  = p_srcY;
	rect.right = rect.left + p_width;
	rect.bottom = rect.top + p_height;
	
	//D3DXVECTOR3 Center = D3DXVECTOR3(10, 10, 1);          // 材质的矩形区域的中心点
	D3DXVECTOR3 Position = D3DXVECTOR3((float)p_destX, (float)p_destY, 0);   // 画的位置
	
	pSprite->Begin(D3DXSPRITE_ALPHABLEND);
	D3DXVECTOR2 Scaling(p_XScale, p_YScale);                         // 縮放比例
	/*D3DXVECTOR2 RotationCenter( p_destX + p_width / 2,
								p_destY + p_height / 2 );*/
	D3DXMATRIX  Matrix;  // 坐标转换矩阵 
	D3DXVECTOR2 d3dx_vector2((float)p_destX, (float)p_destY);
	D3DXMatrixTransformation2D(&Matrix, &d3dx_vector2, 
		0.0, &Scaling, p_pRotationCenter, p_angle, 0 );
	pSprite->SetTransform(&Matrix);
	pSprite->Draw( m_pTexture, &rect, NULL, &Position, p_color);
	pSprite->End();
	return true;
}
Пример #14
0
void renderScene(void) {
  int sx = glutGet(GLUT_WINDOW_WIDTH);
  int sy = glutGet(GLUT_WINDOW_HEIGHT);
  //SAspect = Scaling(1, (float)sx / sy, 1);
  VECTOR4D worldRayOrigin, worldRayDir;
  VECTOR4D modelRayOrigin, modelRayDir;
  MATRIX4D InvW;
  multimap<float, CMesh::INTERSECTIONINFO> faces;
  bool fill = false;

  SAspect = Scaling((float)sy / sx, 1, 1);
  W = Identity();

  P = PerspectiveWidthHeightRH(0.5f, 0.5f, 1.0f, 10.0f);
  EC = SAspect * T * Translation(0.0f, 0.0f, -1.0f);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  BuildRayFromPerspective(EC, mx, my, worldRayOrigin, worldRayDir);
  Inverse(W, InvW);
  modelRayOrigin = InvW * worldRayOrigin;
  modelRayDir = InvW * worldRayDir;
  fill = g_EggCarton.RayCast(modelRayOrigin, modelRayDir, faces);

  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  glBegin(GL_TRIANGLES);
  g_EggCarton.Draw(EC);
  glEnd();
  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  glBegin(GL_TRIANGLES);
  if (fill)
    g_EggCarton.Draw(EC, faces.begin()->second.Face, 1);
  glEnd();

  if (bWireframe)
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  else
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  glBegin(GL_TRIANGLES);
  g_Plate.Draw(SAspect * T * Translation(0.0f, 0.0f, -0.1f));
  g_Sphere.Draw(SAspect * T * Translation(0.4f, 0.4f, 0.32f));
  g_Bananas.Draw(SAspect * T * Translation(0.45f, 0.45f, 0.48f));
  g_Flower.Draw(SAspect * T * Translation(-0.5f, 0.5f, 0.8f));
  glEnd();

  glutSwapBuffers();
}
Пример #15
0
Matrix4f Model::getModelMatrix() const {
    Matrix4f M;
    Matrix3f R = rotation.toRotationMatrix();
    M.setIdentity();
    // then rotate
    M.block<3,3>(0,0) = R;
    // then scale
    M = M * Scaling(Vector4f(scale, scale, scale, 1));
    // translate to center first
    Affine3f a(Translation3f(-center));
    M = M * a.matrix();

    // finally set position
    M.block<3,1>(0,3) += position;

    return M;
}
Пример #16
0
void on_draw_frame() {
    //glClearColor(0.30f, 0.74f, 0.20f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    // Set the blending function (normal w/ premultiplied alpha)
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    update_life_cycle();
    // Create Projection Matrix
    float aspectRatio = 768.0f / 1022;
    Affine3f m;
    m = Scaling(1.0f, aspectRatio, 1.0f);
    Matrix4f projectionMatrix = Matrix4f::Identity();
    projectionMatrix = m.matrix();
    // Render Emitter
    if (s_emitters.size() > 0) {
      std::vector<EmitterObject*>::iterator it = s_emitters.begin();
      for (; it != s_emitters.end(); ++it) {
        (*it)->RenderWithProjection(projectionMatrix);
      }
    }
/*
 
    glUseProgram(program);
 
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texture);
    glUniform1i(u_texture_unit_location, 0);
 
    glBindBuffer(GL_ARRAY_BUFFER, buffer);
    glVertexAttribPointer(a_position_location, 2, GL_FLOAT, GL_FALSE, 
        4 * sizeof(GL_FLOAT), BUFFER_OFFSET(0));
    glVertexAttribPointer(a_texture_coordinates_location, 2, GL_FLOAT, GL_FALSE, 
        4 * sizeof(GL_FLOAT), BUFFER_OFFSET(2 * sizeof(GL_FLOAT)));
    glEnableVertexAttribArray(a_position_location);
    glEnableVertexAttribArray(a_texture_coordinates_location);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
    glBindBuffer(GL_ARRAY_BUFFER, 0);
*/
}
Пример #17
0
void renderScene(void) {
  int sx = glutGet(GLUT_WINDOW_WIDTH);
  int sy = glutGet(GLUT_WINDOW_HEIGHT);
  MATRIX4D SAspect = Scaling((float)sy / sx, 1, 1);
  //MATRIX4D SAspect = Scaling(1, (float)sx / sy, 1);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  if(bWireframe)
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  else
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

  glBegin(GL_TRIANGLES);
    g_EggCarton.Draw(SAspect * T * Translation(0.0f, 0.0f, -1.0f));
    g_Plate.Draw(SAspect * T * Translation(0.0f, 0.0f, -0.1f));
    g_Sphere.Draw(SAspect * T * Translation(0.4f, 0.4f, 0.32f));
    g_Bananas.Draw(SAspect * T * Translation(0.45f, 0.45f, 0.48f));
    g_Flower.Draw(SAspect * T * Translation(-0.5f, 0.5f, 0.8f));
  glEnd();

  glutSwapBuffers();
}
Пример #18
0
//===============================================
//処理
//===============================================
void CEffect::Exec()
{
	//SetPosition(
	
	if(m_IsVariable)
	{
		Translation(m_vPos.x, m_vPos.y, m_vPos.z);
		
		Scaling(m_vScale.x, m_vScale.y, m_vScale.z);
		
		//Heading(m_vRot.x);
		//
		Pitching(m_vRot.x);
		//
		//Rolling(m_vRot.x);
		
		Render(Joker::GetDevice());
		
		m_pAnimController->AdvanceTime(m_AnimSpeed, NULL);
		
		SetWorldMatrix();
	}
	
}
Пример #19
0
int main(void)
{
    //assign X component
    vec1[0] = 2.0;

    //assign Y component
    vec1[1] = 2.0;

    //assign Z component
    vec1[2] = 2.0;

    vec2[0] = 5.0;

    vec2[1] = 5.0;

    vec2[2] = 5.0;

    VectorAdd(vec1,vec2,vec3);
    printf("Vector addition: ");
    int i;
    for(i = 0; i < 3; i++)
    {
        printf("%g ", vec3[i]);
    }

    VectorSubtract(vec1,vec2,vec3);
    printf("\nVector subtraction: ");
    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)
    {
        printf("%g ", vec3[i]);
    }

    DotProduct(vec1,vec2,cheez);
    printf("\nDot product: %g", cheez);

    Scaling(vec1, 2);
    printf("\nScaling by 2: ");
    for(i = 0; i < sizeof(vec1)/sizeof(int); i++)
    {
        printf("%g ", vec1[i]);
    }

    VCopy(vec1, vec3);
    printf("\nCopying vec1 to vec3: ");
    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)
    {
        printf("%g ", vec3[i]);
    }

    VClear(vec3);
    printf("\nClearing vec3: ");
    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)
    {
        printf("%g ", vec3[i]);
    }

    Inverse(vec2);
    printf("\nInverse of vec2: ");
    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)
    {
        printf("%g ", vec2[i]);
    }

    Cross(vec1, vec2, vec3);
    printf("\nCross of vec1 and vec2: ");
    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)
    {
        printf("%g ", vec3[i]);
    }

    Magnitude(vec2);
    printf("\nMagnitude of vec2: ");
    printf("%g ", Magnitude(vec2));

    Normalize(vec2);
    printf("\nNormalize of vec2: ");
    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)
    {
        printf("%g ", vec2[i]);
    }
}
Пример #20
0
Matrix Matrix::TRS(Vector3& translation, Quaternion& rotation, Vector3& scaling)
{
    return Scaling(scaling) * Rotation(rotation) * Translation(translation);
}
Пример #21
0
Matrix Transformation::Scaling ( Vector _ScalingFactors )
{
	//Calls the function above
	return Scaling ( _ScalingFactors.x, _ScalingFactors.y, _ScalingFactors.z );
}
Пример #22
0
ContourAttributes::Scaling
ContourAttributes::GetScaling() const
{
    return Scaling(scaling);
}
Пример #23
0
void
ContourAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ContourAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;

    // Set the default palette from the values in the DataNode.
    if((node = searchNode->GetNode("defaultPalette")) != 0)
        defaultPalette.SetFromNode(node);

    if((node = searchNode->GetNode("colorType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetColorType(ColoringMethod(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ColoringMethod value;
            if(ColoringMethod_FromString(node->AsString(), value))
                SetColorType(value);
        }
    }
    if((node = searchNode->GetNode("colorTableName")) != 0)
        SetColorTableName(node->AsString());
    if((node = searchNode->GetNode("legendFlag")) != 0)
        SetLegendFlag(node->AsBool());
    if((node = searchNode->GetNode("invertColorTable")) != 0)
        SetInvertColorTable(node->AsBool());
    if((node = searchNode->GetNode("lineStyle")) != 0)
        SetLineStyle(node->AsInt());
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("singleColor")) != 0)
        singleColor.SetFromNode(node);
    if((node = searchNode->GetNode("contourNLevels")) != 0)
        SetContourNLevels(node->AsInt());
    if((node = searchNode->GetNode("contourValue")) != 0)
        SetContourValue(node->AsDoubleVector());
    if((node = searchNode->GetNode("contourPercent")) != 0)
        SetContourPercent(node->AsDoubleVector());
    if((node = searchNode->GetNode("contourMethod")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetContourMethod(Select_by(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Select_by value;
            if(Select_by_FromString(node->AsString(), value))
                SetContourMethod(value);
        }
    }
    if((node = searchNode->GetNode("minFlag")) != 0)
        SetMinFlag(node->AsBool());
    if((node = searchNode->GetNode("maxFlag")) != 0)
        SetMaxFlag(node->AsBool());
    if((node = searchNode->GetNode("min")) != 0)
        SetMin(node->AsDouble());
    if((node = searchNode->GetNode("max")) != 0)
        SetMax(node->AsDouble());
    if((node = searchNode->GetNode("scaling")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetScaling(Scaling(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Scaling value;
            if(Scaling_FromString(node->AsString(), value))
                SetScaling(value);
        }
    }
    if((node = searchNode->GetNode("wireframe")) != 0)
        SetWireframe(node->AsBool());
}
Пример #24
0
void
SurfaceAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SurfaceAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("legendFlag")) != 0)
        SetLegendFlag(node->AsBool());
    if((node = searchNode->GetNode("lightingFlag")) != 0)
        SetLightingFlag(node->AsBool());
    if((node = searchNode->GetNode("surfaceFlag")) != 0)
        SetSurfaceFlag(node->AsBool());
    if((node = searchNode->GetNode("wireframeFlag")) != 0)
        SetWireframeFlag(node->AsBool());
    if((node = searchNode->GetNode("limitsMode")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetLimitsMode(LimitsMode(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            LimitsMode value;
            if(LimitsMode_FromString(node->AsString(), value))
                SetLimitsMode(value);
        }
    }
    if((node = searchNode->GetNode("minFlag")) != 0)
        SetMinFlag(node->AsBool());
    if((node = searchNode->GetNode("maxFlag")) != 0)
        SetMaxFlag(node->AsBool());
    if((node = searchNode->GetNode("colorByZFlag")) != 0)
        SetColorByZFlag(node->AsBool());
    if((node = searchNode->GetNode("scaling")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetScaling(Scaling(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Scaling value;
            if(Scaling_FromString(node->AsString(), value))
                SetScaling(value);
        }
    }
    if((node = searchNode->GetNode("lineStyle")) != 0)
        SetLineStyle(node->AsInt());
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("surfaceColor")) != 0)
        surfaceColor.SetFromNode(node);
    if((node = searchNode->GetNode("wireframeColor")) != 0)
        wireframeColor.SetFromNode(node);
    if((node = searchNode->GetNode("skewFactor")) != 0)
        SetSkewFactor(node->AsDouble());
    if((node = searchNode->GetNode("min")) != 0)
        SetMin(node->AsDouble());
    if((node = searchNode->GetNode("max")) != 0)
        SetMax(node->AsDouble());
    if((node = searchNode->GetNode("colorTableName")) != 0)
        SetColorTableName(node->AsString());
    if((node = searchNode->GetNode("invertColorTable")) != 0)
        SetInvertColorTable(node->AsBool());
}
void
SurfaceFilterAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SurfaceFilterAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("limitsMode")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetLimitsMode(LimitsMode(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            LimitsMode value;
            if(LimitsMode_FromString(node->AsString(), value))
                SetLimitsMode(value);
        }
    }
    if((node = searchNode->GetNode("minFlag")) != 0)
        SetMinFlag(node->AsBool());
    if((node = searchNode->GetNode("maxFlag")) != 0)
        SetMaxFlag(node->AsBool());
    if((node = searchNode->GetNode("scaling")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetScaling(Scaling(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Scaling value;
            if(Scaling_FromString(node->AsString(), value))
                SetScaling(value);
        }
    }
    if((node = searchNode->GetNode("skewFactor")) != 0)
        SetSkewFactor(node->AsDouble());
    if((node = searchNode->GetNode("min")) != 0)
        SetMin(node->AsDouble());
    if((node = searchNode->GetNode("max")) != 0)
        SetMax(node->AsDouble());
    if((node = searchNode->GetNode("zeroFlag")) != 0)
        SetZeroFlag(node->AsBool());
    if((node = searchNode->GetNode("variable")) != 0)
        SetVariable(node->AsString());
    if((node = searchNode->GetNode("useXYLimits")) != 0)
        SetUseXYLimits(node->AsBool());
    if((node = searchNode->GetNode("generateNodalOutput")) != 0)
        SetGenerateNodalOutput(node->AsBool());
}
Пример #26
0
dhVector dhVector::operator*(REAL r)        // cross operator
{
dhVector temp;
	temp	= Scaling(r);
	return temp;
}
Пример #27
0
dhVector dhVector::Scaling( dhVector s)
{
	return Scaling( s.x,s.y,s.z );
}
SurfaceFilterAttributes::Scaling
SurfaceFilterAttributes::GetScaling() const
{
    return Scaling(scaling);
}
template<typename Scalar, int Mode, int Options> void transformations()
{
  /* this test covers the following files:
     Cross.h Quaternion.h, Transform.cpp
  */
  typedef Matrix<Scalar,2,2> Matrix2;
  typedef Matrix<Scalar,3,3> Matrix3;
  typedef Matrix<Scalar,4,4> Matrix4;
  typedef Matrix<Scalar,2,1> Vector2;
  typedef Matrix<Scalar,3,1> Vector3;
  typedef Matrix<Scalar,4,1> Vector4;
  typedef Quaternion<Scalar> Quaternionx;
  typedef AngleAxis<Scalar> AngleAxisx;
  typedef Transform<Scalar,2,Mode,Options> Transform2;
  typedef Transform<Scalar,3,Mode,Options> Transform3;
  typedef Transform<Scalar,2,Isometry,Options> Isometry2;
  typedef Transform<Scalar,3,Isometry,Options> Isometry3;
  typedef typename Transform3::MatrixType MatrixType;
  typedef DiagonalMatrix<Scalar,2> AlignedScaling2;
  typedef DiagonalMatrix<Scalar,3> AlignedScaling3;
  typedef Translation<Scalar,2> Translation2;
  typedef Translation<Scalar,3> Translation3;

  Vector3 v0 = Vector3::Random(),
          v1 = Vector3::Random();
  Matrix3 matrot1, m;

  Scalar a = internal::random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
  Scalar s0 = internal::random<Scalar>();

  VERIFY_IS_APPROX(v0, AngleAxisx(a, v0.normalized()) * v0);
  VERIFY_IS_APPROX(-v0, AngleAxisx(Scalar(M_PI), v0.unitOrthogonal()) * v0);
  VERIFY_IS_APPROX(internal::cos(a)*v0.squaredNorm(), v0.dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
  m = AngleAxisx(a, v0.normalized()).toRotationMatrix().adjoint();
  VERIFY_IS_APPROX(Matrix3::Identity(), m * AngleAxisx(a, v0.normalized()));
  VERIFY_IS_APPROX(Matrix3::Identity(), AngleAxisx(a, v0.normalized()) * m);

  Quaternionx q1, q2;
  q1 = AngleAxisx(a, v0.normalized());
  q2 = AngleAxisx(a, v1.normalized());

  // rotation matrix conversion
  matrot1 = AngleAxisx(Scalar(0.1), Vector3::UnitX())
          * AngleAxisx(Scalar(0.2), Vector3::UnitY())
          * AngleAxisx(Scalar(0.3), Vector3::UnitZ());
  VERIFY_IS_APPROX(matrot1 * v1,
       AngleAxisx(Scalar(0.1), Vector3(1,0,0)).toRotationMatrix()
    * (AngleAxisx(Scalar(0.2), Vector3(0,1,0)).toRotationMatrix()
    * (AngleAxisx(Scalar(0.3), Vector3(0,0,1)).toRotationMatrix() * v1)));

  // angle-axis conversion
  AngleAxisx aa = AngleAxisx(q1);
  VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1);
  VERIFY_IS_NOT_APPROX(q1 * v1, Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1);

  aa.fromRotationMatrix(aa.toRotationMatrix());
  VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1);
  VERIFY_IS_NOT_APPROX(q1 * v1, Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1);

  // AngleAxis
  VERIFY_IS_APPROX(AngleAxisx(a,v1.normalized()).toRotationMatrix(),
    Quaternionx(AngleAxisx(a,v1.normalized())).toRotationMatrix());

  AngleAxisx aa1;
  m = q1.toRotationMatrix();
  aa1 = m;
  VERIFY_IS_APPROX(AngleAxisx(m).toRotationMatrix(),
    Quaternionx(m).toRotationMatrix());

  // Transform
  // TODO complete the tests !
  a = 0;
  while (internal::abs(a)<Scalar(0.1))
    a = internal::random<Scalar>(-Scalar(0.4)*Scalar(M_PI), Scalar(0.4)*Scalar(M_PI));
  q1 = AngleAxisx(a, v0.normalized());
  Transform3 t0, t1, t2;

  // first test setIdentity() and Identity()
  t0.setIdentity();
  VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity());
  t0.matrix().setZero();
  t0 = Transform3::Identity();
  VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity());

  t0.setIdentity();
  t1.setIdentity();
  v1 << 1, 2, 3;
  t0.linear() = q1.toRotationMatrix();
  t0.pretranslate(v0);
  t0.scale(v1);
  t1.linear() = q1.conjugate().toRotationMatrix();
  t1.prescale(v1.cwiseInverse());
  t1.translate(-v0);

  VERIFY((t0 * t1).matrix().isIdentity(test_precision<Scalar>()));

  t1.fromPositionOrientationScale(v0, q1, v1);
  VERIFY_IS_APPROX(t1.matrix(), t0.matrix());

  t0.setIdentity(); t0.scale(v0).rotate(q1.toRotationMatrix());
  t1.setIdentity(); t1.scale(v0).rotate(q1);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  t0.setIdentity(); t0.scale(v0).rotate(AngleAxisx(q1));
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  VERIFY_IS_APPROX(t0.scale(a).matrix(), t1.scale(Vector3::Constant(a)).matrix());
  VERIFY_IS_APPROX(t0.prescale(a).matrix(), t1.prescale(Vector3::Constant(a)).matrix());

  // More transform constructors, operator=, operator*=

  Matrix3 mat3 = Matrix3::Random();
  Matrix4 mat4;
  mat4 << mat3 , Vector3::Zero() , Vector4::Zero().transpose();
  Transform3 tmat3(mat3), tmat4(mat4);
  if(Mode!=int(AffineCompact))
    tmat4.matrix()(3,3) = Scalar(1);
  VERIFY_IS_APPROX(tmat3.matrix(), tmat4.matrix());

  Scalar a3 = internal::random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
  Vector3 v3 = Vector3::Random().normalized();
  AngleAxisx aa3(a3, v3);
  Transform3 t3(aa3);
  Transform3 t4;
  t4 = aa3;
  VERIFY_IS_APPROX(t3.matrix(), t4.matrix());
  t4.rotate(AngleAxisx(-a3,v3));
  VERIFY_IS_APPROX(t4.matrix(), MatrixType::Identity());
  t4 *= aa3;
  VERIFY_IS_APPROX(t3.matrix(), t4.matrix());

  v3 = Vector3::Random();
  Translation3 tv3(v3);
  Transform3 t5(tv3);
  t4 = tv3;
  VERIFY_IS_APPROX(t5.matrix(), t4.matrix());
  t4.translate(-v3);
  VERIFY_IS_APPROX(t4.matrix(), MatrixType::Identity());
  t4 *= tv3;
  VERIFY_IS_APPROX(t5.matrix(), t4.matrix());

  AlignedScaling3 sv3(v3);
  Transform3 t6(sv3);
  t4 = sv3;
  VERIFY_IS_APPROX(t6.matrix(), t4.matrix());
  t4.scale(v3.cwiseInverse());
  VERIFY_IS_APPROX(t4.matrix(), MatrixType::Identity());
  t4 *= sv3;
  VERIFY_IS_APPROX(t6.matrix(), t4.matrix());

  // matrix * transform
  VERIFY_IS_APPROX((t3.matrix()*t4).matrix(), (t3*t4).matrix());

  // chained Transform product
  VERIFY_IS_APPROX(((t3*t4)*t5).matrix(), (t3*(t4*t5)).matrix());

  // check that Transform product doesn't have aliasing problems
  t5 = t4;
  t5 = t5*t5;
  VERIFY_IS_APPROX(t5, t4*t4);

  // 2D transformation
  Transform2 t20, t21;
  Vector2 v20 = Vector2::Random();
  Vector2 v21 = Vector2::Random();
  for (int k=0; k<2; ++k)
    if (internal::abs(v21[k])<Scalar(1e-3)) v21[k] = Scalar(1e-3);
  t21.setIdentity();
  t21.linear() = Rotation2D<Scalar>(a).toRotationMatrix();
  VERIFY_IS_APPROX(t20.fromPositionOrientationScale(v20,a,v21).matrix(),
    t21.pretranslate(v20).scale(v21).matrix());

  t21.setIdentity();
  t21.linear() = Rotation2D<Scalar>(-a).toRotationMatrix();
  VERIFY( (t20.fromPositionOrientationScale(v20,a,v21)
        * (t21.prescale(v21.cwiseInverse()).translate(-v20))).matrix().isIdentity(test_precision<Scalar>()) );

  // Transform - new API
  // 3D
  t0.setIdentity();
  t0.rotate(q1).scale(v0).translate(v0);
  // mat * aligned scaling and mat * translation
  t1 = (Matrix3(q1) * AlignedScaling3(v0)) * Translation3(v0);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  t1 = (Matrix3(q1) * Eigen::Scaling(v0)) * Translation3(v0);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  t1 = (q1 * Eigen::Scaling(v0)) * Translation3(v0);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  // mat * transformation and aligned scaling * translation
  t1 = Matrix3(q1) * (AlignedScaling3(v0) * Translation3(v0));
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());


  t0.setIdentity();
  t0.scale(s0).translate(v0);
  t1 = Eigen::Scaling(s0) * Translation3(v0);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  t0.prescale(s0);
  t1 = Eigen::Scaling(s0) * t1;
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  
  t0 = t3;
  t0.scale(s0);
  t1 = t3 * Eigen::Scaling(s0,s0,s0);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  t0.prescale(s0);
  t1 = Eigen::Scaling(s0,s0,s0) * t1;
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());


  t0.setIdentity();
  t0.prerotate(q1).prescale(v0).pretranslate(v0);
  // translation * aligned scaling and transformation * mat
  t1 = (Translation3(v0) * AlignedScaling3(v0)) * Transform3(q1);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  // scaling * mat and translation * mat
  t1 = Translation3(v0) * (AlignedScaling3(v0) * Transform3(q1));
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  t0.setIdentity();
  t0.scale(v0).translate(v0).rotate(q1);
  // translation * mat and aligned scaling * transformation
  t1 = AlignedScaling3(v0) * (Translation3(v0) * Transform3(q1));
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  // transformation * aligned scaling
  t0.scale(v0);
  t1 *= AlignedScaling3(v0);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  // transformation * translation
  t0.translate(v0);
  t1 = t1 * Translation3(v0);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
  // translation * transformation
  t0.pretranslate(v0);
  t1 = Translation3(v0) * t1;
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  // transform * quaternion
  t0.rotate(q1);
  t1 = t1 * q1;
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  // translation * quaternion
  t0.translate(v1).rotate(q1);
  t1 = t1 * (Translation3(v1) * q1);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  // aligned scaling * quaternion
  t0.scale(v1).rotate(q1);
  t1 = t1 * (AlignedScaling3(v1) * q1);
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  // quaternion * transform
  t0.prerotate(q1);
  t1 = q1 * t1;
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  // quaternion * translation
  t0.rotate(q1).translate(v1);
  t1 = t1 * (q1 * Translation3(v1));
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  // quaternion * aligned scaling
  t0.rotate(q1).scale(v1);
  t1 = t1 * (q1 * AlignedScaling3(v1));
  VERIFY_IS_APPROX(t0.matrix(), t1.matrix());

  // test transform inversion
  t0.setIdentity();
  t0.translate(v0);
  t0.linear().setRandom();
  Matrix4 t044 = Matrix4::Zero();
  t044(3,3) = 1;
  t044.block(0,0,t0.matrix().rows(),4) = t0.matrix();
  VERIFY_IS_APPROX(t0.inverse(Affine).matrix(), t044.inverse().block(0,0,t0.matrix().rows(),4));
  t0.setIdentity();
  t0.translate(v0).rotate(q1);
  t044 = Matrix4::Zero();
  t044(3,3) = 1;
  t044.block(0,0,t0.matrix().rows(),4) = t0.matrix();
  VERIFY_IS_APPROX(t0.inverse(Isometry).matrix(), t044.inverse().block(0,0,t0.matrix().rows(),4));

  Matrix3 mat_rotation, mat_scaling;
  t0.setIdentity();
  t0.translate(v0).rotate(q1).scale(v1);
  t0.computeRotationScaling(&mat_rotation, &mat_scaling);
  VERIFY_IS_APPROX(t0.linear(), mat_rotation * mat_scaling);
  VERIFY_IS_APPROX(mat_rotation*mat_rotation.adjoint(), Matrix3::Identity());
  VERIFY_IS_APPROX(mat_rotation.determinant(), Scalar(1));
  t0.computeScalingRotation(&mat_scaling, &mat_rotation);
  VERIFY_IS_APPROX(t0.linear(), mat_scaling * mat_rotation);
  VERIFY_IS_APPROX(mat_rotation*mat_rotation.adjoint(), Matrix3::Identity());
  VERIFY_IS_APPROX(mat_rotation.determinant(), Scalar(1));

  // test casting
  Transform<float,3,Mode> t1f = t1.template cast<float>();
  VERIFY_IS_APPROX(t1f.template cast<Scalar>(),t1);
  Transform<double,3,Mode> t1d = t1.template cast<double>();
  VERIFY_IS_APPROX(t1d.template cast<Scalar>(),t1);

  Translation3 tr1(v0);
  Translation<float,3> tr1f = tr1.template cast<float>();
  VERIFY_IS_APPROX(tr1f.template cast<Scalar>(),tr1);
  Translation<double,3> tr1d = tr1.template cast<double>();
  VERIFY_IS_APPROX(tr1d.template cast<Scalar>(),tr1);

  AngleAxis<float> aa1f = aa1.template cast<float>();
  VERIFY_IS_APPROX(aa1f.template cast<Scalar>(),aa1);
  AngleAxis<double> aa1d = aa1.template cast<double>();
  VERIFY_IS_APPROX(aa1d.template cast<Scalar>(),aa1);

  Rotation2D<Scalar> r2d1(internal::random<Scalar>());
  Rotation2D<float> r2d1f = r2d1.template cast<float>();
  VERIFY_IS_APPROX(r2d1f.template cast<Scalar>(),r2d1);
  Rotation2D<double> r2d1d = r2d1.template cast<double>();
  VERIFY_IS_APPROX(r2d1d.template cast<Scalar>(),r2d1);

  t20 = Translation2(v20) * (Rotation2D<Scalar>(s0) * Scaling(s0));
  t21 = Translation2(v20) * Rotation2D<Scalar>(s0) * Scaling(s0);
  VERIFY_IS_APPROX(t20,t21);
}