glTranslate*, glScale*, glRotate*的使用练习

GlLookAt的用法 OpenGL中的坐标系之间的变换,它们如下: 本地坐标系-->世界坐标系-->眼坐标系-->裁剪坐标系 一般gluLookAt()用于从世界坐标系到眼坐标系的转换,但是由于OpenGL里面模型视图矩阵直接将本地坐标系转换为眼坐标系,所以gluLookAt()应该被用来设置模型视图矩阵,但是有一点得注意了: gluLookAt()的调用应该在场景绘制初glLoadIdentity()函数调用之 阅读详情
#include <iostream>
#include <map>
#include "gl/glew.h"
#include "gl/glut.h"
using namespace std;
enum FingerJoint
{
 Shoulder_Joint,   //The joint which connects the shoulder to the body.
 Elbow_Joint,   //The joint which connects the two parts of arm.
 Wrist_Joint,   //The joint which connects the wrist to the arm.
 Thumb_1st_Joint,  //The joint which connects the thumb to palm
 Thumb_2nd_Joint,  //The joint which connects two parts of the thumb
 Forefinger_1st_Joint, //The joint which connects the forefinger to palm
 Forefinger_2nd_Joint, //The joint which connects the two parts of the forefinger
 Forefinger_3rd_Joint,
 MiddleFinger_1st_Joint, //The joint which connects the middle finger to palm
 MiddleFinger_2nd_Joint, 
 MiddleFinger_3rd_Joint,
 Ringfinger_1st_Joint, //The joint which connects the ring finger to palm
 Ringfinger_2nd_Joint, 
 Ringfinger_3rd_Joint,
 LittleFinger_1st_Joint, //The joint which connects the little finger to palm
 LittleFinger_2nd_Joint, //
 LittleFinger_3rd_Joint,
 JointCount    //Total joints count
};
//The rotation angels of all joints
GLfloat gFingerJointRotations[JointCount];
//The limit of the rotation angel for all fingers is between 0~90
const GLfloat FingerJointRotationMax = 90.0f; //Max rotation angel
const GLfloat FingerJointRotationMin = 0.0f; //Min rotation angel
const GLfloat RotationDelta = 5.0f;
//The rotation Angel of the Shoulder, range between -45.0~90
const GLfloat ShoulderRotationMax = 90.0f;
const GLfloat ShoulderRotationMin = -45.0f;
//The rotation angel of the elbow, range between 0~160
const GLfloat ElbowRotationMax = 160.0f;
const GLfloat ElbowRotationMin = 0.0f;
  
//The rotation angel of the wrist, range between -60~80
const GLfloat WristRotationMax = 80.0f;
const GLfloat WristRotationMin = -60.0f;
class ControlData
{
public:
 ControlData()
 {}
 ControlData(int index, GLfloat delta, GLfloat min, GLfloat max)
  :Index(index), Delta(delta), MinValue(min), MaxValue(max)
 {}
 ControlData(const ControlData &other)
  :Index(other.Index), Delta(other.Delta), MinValue(other.MinValue), MaxValue(other.MaxValue)
 {}
 ControlData& operator = (const ControlData &other)
 {
  Index = other.Index;
  MaxValue = other.MaxValue;
  MinValue = other.MinValue;
  Delta = other.Delta;
  return *this;
 }
 int Index;   //Index of Joint Rotation Angel
 GLfloat MaxValue; //Max angel
 GLfloat MinValue; //Min angel
 GLfloat Delta;  //Delta value
};
std::map<GLubyte, ControlData> gKeyControlDataMap;
/*
 Initialize Key-Rotation Data mapping.
**/
void initControlMapping()
{
 //All char press without shift will rotate deasil
 //All char press with shift will rotate widdershins
 gKeyControlDataMap['a'] = ControlData(Shoulder_Joint, RotationDelta, ShoulderRotationMin, ShoulderRotationMax);
 gKeyControlDataMap['A'] = ControlData(Shoulder_Joint, -RotationDelta, ShoulderRotationMin, ShoulderRotationMax);
 gKeyControlDataMap['s'] = ControlData(Elbow_Joint, RotationDelta, ElbowRotationMin, ElbowRotationMax);
 gKeyControlDataMap['S'] = ControlData(Elbow_Joint, -RotationDelta, ElbowRotationMin, ElbowRotationMax);
 gKeyControlDataMap['d'] = ControlData(Wrist_Joint, RotationDelta, WristRotationMin, WristRotationMax);
 gKeyControlDataMap['D'] = ControlData(Wrist_Joint, -RotationDelta, WristRotationMin, WristRotationMax);
 gKeyControlDataMap['n'] = ControlData(Thumb_1st_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['N'] = ControlData(Thumb_1st_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['h'] = ControlData(Thumb_2nd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['H'] = ControlData(Thumb_2nd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['m'] = ControlData(Forefinger_1st_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['M'] = ControlData(Forefinger_1st_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['j'] = ControlData(Forefinger_2nd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['J'] = ControlData(Forefinger_2nd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['u'] = ControlData(Forefinger_3rd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['U'] = ControlData(Forefinger_3rd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap[','] = ControlData(MiddleFinger_1st_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['<'] = ControlData(MiddleFinger_1st_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['k'] = ControlData(MiddleFinger_2nd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['K'] = ControlData(MiddleFinger_2nd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['i'] = ControlData(MiddleFinger_3rd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['I'] = ControlData(MiddleFinger_3rd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['.'] = ControlData(Ringfinger_1st_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['>'] = ControlData(Ringfinger_1st_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['l'] = ControlData(Ringfinger_2nd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['L'] = ControlData(Ringfinger_2nd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['o'] = ControlData(Ringfinger_3rd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['O'] = ControlData(Ringfinger_3rd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['/'] = ControlData(LittleFinger_1st_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['?'] = ControlData(LittleFinger_1st_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap[';'] = ControlData(LittleFinger_2nd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap[':'] = ControlData(LittleFinger_2nd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['p'] = ControlData(LittleFinger_3rd_Joint, RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
 gKeyControlDataMap['P'] = ControlData(LittleFinger_3rd_Joint, -RotationDelta, FingerJointRotationMin, FingerJointRotationMax);
}
void init()
{
 initControlMapping();
 //Set background color : black
 glClearColor(0.0, 0.0, 0.0, 0.0);
 glShadeModel(GL_SMOOTH);
 //Enable Depth test
 glEnable(GL_DEPTH_TEST);
 //Enable lighting
 glEnable(GL_LIGHTING);
 //Set Light source 0
 static GLfloat light0_position[] = {1.0, 1.0, 1.0, 0.0};
 glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
 //Blue light
 static GLfloat light0_diffuse[] = {1.0, 1.0, 1.0, 1.0};
 glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
 //Enable the 1st light source.
 glEnable(GL_LIGHT0);
}

/*
 Window reshape event callback, call the function once the window size changed.
**/
void reshape(GLsizei w, GLsizei h)
{
 //Avoid divide 0
 if(0==h)
    h=1;
 //Set the view port
 glViewport(0, 0, w, h);
 //All matrix operations will affect projection matrix
 glMatrixMode(GL_PROJECTION);
 //Load an identity matrix
 glLoadIdentity();
 //Set projection matrix
 gluPerspective(45.0, (GLfloat)w/(GLfloat)h, 0.1, 500.0);
 //All matrix operations will affect model veiw matrix
 glMatrixMode(GL_MODELVIEW);
}

/*
 Redraw callback, call this function every time the display need to refresh.
**/
void display()
{
 //Clear color buffer and depth buffer
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 glLoadIdentity();
 //Set camera parameters
 gluLookAt(0.0, 0.0, 60.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
 //Rotate camera
 glRotatef(150.0, 0.0, 1.0, 0.0);
 //Draw the shoulder
 glTranslatef(6.0, 0.0, 0.0);
 glRotatef(gFingerJointRotations[Shoulder_Joint], 0.0, 0.0, 1.0);
 glScalef(12.0, 2.0, 4.0);
 glutSolidCube(1.0);
 //Eliminate the impact to following objects
 glScalef(1.0/12.0, 1.0/2.0, 1.0/4.0);
 
 //Draw the elbow, use the transform matrix of shoulder as parent matrix
 glTranslatef(6.0, 0.0, 0.0);
 glRotatef(gFingerJointRotations[Elbow_Joint], 0.0, 0.0, 1.0);
 //Translate twice, make sure the rotation center at the end of the elbow
 glTranslatef(6.0, 0.0, 0.0);  
 glScalef(12.0, 2.0, 4.0);
 glutSolidCube(1.0);
 //Eliminate the impact to following objects
 glScalef(1.0/12.0, 1.0/2.0, 1.0/4.0);
 {
  //Draw the palm, use the transform matrix of elbow as parent matrix
  glPushMatrix();  //push current matrix to stack
  glTranslatef(6.0, 0.0, 0.0);
  glRotatef(gFingerJointRotations[Wrist_Joint], 0.0, 0.0, 1.0);
  glTranslatef(3.0, 0.0, 0.0);
  glScalef(6.0, 1.0, 4.0);
  glutSolidCube(1.0);
  //Eliminate the impact to following objects
  glScalef(1.0/6.0, 1.0, 1.0/4.0);
  {
   //Draw thumb, use the transform matrix of palm as parent matrix
   glPushMatrix();
   glTranslatef(-1.0, 0.0, -1.0);
   glRotatef(-gFingerJointRotations[Thumb_1st_Joint], 0.0, 0.0, 1.0);
   glRotatef(gFingerJointRotations[Thumb_1st_Joint], 1.0, 0.0, 0.0);
   //Translate twice, make sure the rotation center at the end of the thumb
   glTranslatef(-1.0, 0.0, -2.0);
   glScalef(1.0, 1.0, 2.0);
   glutSolidCube(1.0);
   //Eliminate the impact to following objects
   glScalef(1.0, 1.0, 1.0/2.0);
   {
    //Draw the 2nd part of thumb,
    //use the transform matrix of the first part of thumb as parent matrix
    glPushMatrix();
    glTranslatef(0.0, 0.0, -1.0);
    glRotatef(gFingerJointRotations[Thumb_2nd_Joint], 1.0, 0.0, 0.0);
    glTranslatef(0.0, 0.0, 0.0);
    glScalef(1.0, 1.0, 2.0);
    glutSolidCube(1.0);
    glPopMatrix();
   }
   glPopMatrix();
  }
  {
   //Draw the forefinger, use the transform matrix of palm as parent matrix
   glPushMatrix();
   glTranslatef(3.0, 0.0, -1.5);
   glRotatef(gFingerJointRotations[Forefinger_1st_Joint], 0.0, 0.0, 1.0);
   //Translate twice, make sure the rotation center at the end of the 1st part of forefinger
   glTranslatef(1.0, 0.0, 0.0);
   glScalef(2.0, 1.0, 1.0);
   glutSolidCube(1.0);
   //Eliminate the impact to following objects
   glScalef(1.0/2.0, 1.0, 1.0);
   {
    //Draw the 2nd part of forefinger,
    //use the transform matrix of the first part of forefinger as parent matrix
    glPushMatrix();
    glTranslatef(1.0, 0.0, 0.0);
    glRotatef(gFingerJointRotations[Forefinger_2nd_Joint], 0.0, 0.0, 1.0);
    glTranslatef(1.25, 0.0, 0.0);
    glScalef(2.5, 1.0, 1.0);
    glutSolidCube(1.0);
    glPopMatrix();
   }
   glPopMatrix();
  }
  {
   //Draw middle finger, use the transform matrix of palm as parent matrix
   glPushMatrix();
   glTranslatef(3.0, 0.0, -0.5);
   glRotatef(gFingerJointRotations[MiddleFinger_1st_Joint], 0.0, 0.0, 1.0);
   //Translate twice, make sure the rotation center at the end of the 1st part of middle finger
   glTranslatef(1.25, 0.0, 0.0);
   glScalef(2.5, 1.0, 1.0);
   glutSolidCube(1.0);
   //Eliminate the impact to following objects
   glScalef(1.0/2.5, 1.0, 1.0);
   {
    //Draw the 2nd part of middle finger,
    //use the transform matrix of the first part of middle finger as parent matrix
    glPushMatrix();
    glTranslatef(1.25, 0.0, 0.0);
    glRotatef(gFingerJointRotations[MiddleFinger_2nd_Joint], 0.0, 0.0, 1.0);
    //Translate twice, make sure the rotation center at the end of the 2nd part of middle finger
    glTranslatef(1.5, 0.0, 0.0);
    glScalef(3.0, 1.0, 1.0);
    glutSolidCube(1.0);
    glPopMatrix();
   }
   glPopMatrix();
  }
  {
   //Draw ring finger, use the transform matrix of palm as parent matrix
   glPushMatrix();
   glTranslatef(3.0, 0.0, 0.5);
   glRotatef(gFingerJointRotations[Ringfinger_1st_Joint], 0.0, 0.0, 1.0);
   //Translate twice, make sure the rotation center at the end of the 1st part of ring finger
   glTranslatef(1.0, 0.0, 0.0);
   glScalef(2.0, 1.0, 1.0);
   glutSolidCube(1.0);
   //Eliminate the impact to following objects
   glScalef(1.0/2.0, 1.0, 1.0);
   {
    //Draw the 2nd part of ring finger,
    //use the transform matrix of the first part of ring finger as parent matrix
    glPushMatrix();
    glTranslatef(1.0, 0.0, 0.0);
    glRotatef(gFingerJointRotations[Ringfinger_2nd_Joint], 0.0, 0.0, 1.0);
    //Translate twice, make sure the rotation center at the end of the 2nd part of ring finger
    glTranslatef(1.5, 0.0, 0.0);
    glScalef(3.0, 1.0, 1.0);
    glutSolidCube(1.0);
    glPopMatrix();
   }
   glPopMatrix();
  }
  {
   //Draw little finger, use the transform matrix of palm as parent matrix
   glPushMatrix();
   glTranslatef(3.0, 0.0, 1.5);
   glRotatef(gFingerJointRotations[LittleFinger_1st_Joint], 0.0, 0.0, 1.0);
   //Translate twice, make sure the rotation center at the end of the 1st part of little finger
   glTranslatef(0.75, 0.0, 0.0);
   glScalef(1.5, 1.0, 1.0);
   glutSolidCube(1.0);
   //Eliminate the impact to following objects
   glScalef(1.0/1.5, 1.0, 1.0);
   {
    //Draw the 2nd part of little finger,
    //use the transform matrix of the first part of little finger as parent matrix
    glPushMatrix();
    glTranslatef(0.75, 0.0, 0.0);
    glRotatef(gFingerJointRotations[LittleFinger_2nd_Joint], 0.0, 0.0, 1.0);
    //Translate twice, make sure the rotation center at the end of the 2nd part of little finger
    glTranslatef(1.0, 0.0, 0.0);
    glScalef(2.0, 1.0, 1.0);
    glutSolidCube(1.0);
    glPopMatrix();
   }
   glPopMatrix();
  }
  glPopMatrix(); //pop the palm matrix out
 }
 //Swap the buffers
 glutSwapBuffers();
}
/*
 Keyboard event callback
 Handle key down event
**/
void keyboard(GLubyte key, GLint, GLint)
{
 std::map<GLubyte, ControlData>::iterator it = gKeyControlDataMap.find(key);
 if(it != gKeyControlDataMap.end())
 {//If find the registed key, update the rotation of joint
  if ( gFingerJointRotations[it->second.Index] >= it->second.MinValue &&
   it->second.Delta < 0.0f )
  {
   gFingerJointRotations[it->second.Index] += it->second.Delta;
   glutPostRedisplay();
  }
  else if ( gFingerJointRotations[it->second.Index] <= it->second.MaxValue &&
   it->second.Delta > 0.0f)
  {//Within limit
   //Update Rotation Angel
   gFingerJointRotations[it->second.Index] += it->second.Delta;
   //Refresh window
   glutPostRedisplay();
  }
 }
}
int main(int argc, char** argv)
{
 //Initialize glut
 glutInit(&argc, argv);
 //Initialize display mode, use double buffers
 //Color buffer use RGBA format
 //Create depth buffer
 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
 //Create rendering target
 glutInitWindowPosition(200, 100);
 glutInitWindowSize(400, 300);
 glutCreateWindow("Robot");
 
 init();
 //Register redraw callback
 glutDisplayFunc(display);
 //Register window reshape callback
 glutReshapeFunc(reshape);
 //Register keyboard event callback
 glutKeyboardFunc(keyboard);
 //Start message loop
 glutMainLoop();
 return 0;
}
用glut库实现旋转,平移,缩放 平移glTranslate&lt;f,d&gt;(tx,ty,tz),对于二维情形,tz=0.0示例如下:glTranslatef(3.0,2.0f,0.0f);旋转 glRotate&lt;f,d&gt;(theta,vx,vy,vz):    theta,vx,vy,vz指定这个旋转物体的矩阵,物体将绕着(0,0,0)到(x,y,z)的直线以逆时针旋转,参数 theta表示旋转的角度。取正时为... 阅读详情

相关推荐

OpenGL 2D 变换矩阵原理:从 glTranslate/Rotate/Scale 到 4x4 齐次坐标推导

本文深入解析OpenGL 2D变换矩阵的数学原理,从glTranslate/Rotate/Scale函数调用到4x4齐次坐标的推导过程。详细介绍了二维几何变换的数学基础、矩阵构建与组合、齐次坐标系统以及复合变换的数学推导,帮助开发者掌握计算机图形学核心概念。

weixin_34221775的博客 453

OpenGL ES之glRotate函数

名称: glRotate—— 使用一个旋转矩阵乘以当前矩阵 函数原型: void glRotatef(GLfloat angle,  GLfloat x,  GLfloat y,  GLfloat z); void glRotatex(GLfixed angle,  GLfixed x,  GLfixed y,  GLfixed z); 函数参数

飞鱼 1万+

OpenGL几何变换

在OpenGL中,我们提供了三个命令函数来实现平移、旋转和缩放,它们是glTraslate(),glRotate(),glScale()。从而可以确定一个物体在场景中的位置、旋转角度和缩放比例。

OpenGL ES之glRotatef旋转详解

glRotatef函数的API中文参考文档请看:OpenGL ES之glRotate函数       void glRotatef(GLfloat angle,  GLfloat x,  GLfloat y,  GLfloat z);       其中,angle为旋转的角度,单位为度.重点是x,y,z表达的是什么意思呢?应该如何取值?       如果说x,y,z表达的是一个坐标(x

飞鱼 4万+

VMware Workstation 17 Pro 保姆级教程:手把手教你安装银河麒麟 Kylin V10 SP3 国产系统

本文提供VMware Workstation 17 Pro安装银河麒麟Kylin V10 SP3的详细教程,涵盖环境准备、虚拟机配置、系统安装及优化全流程。通过分步指导和实用技巧,帮助用户高效搭建国产操作系统开发测试环境,特别适合技术自主可控需求场景下的虚拟化实践。

weixin_30879169的博客 645

SGLang HiCache实战:手把手教你配置KV Cache Offload,让大模型推理成本直降84%

本文详细介绍了SGLang HiCache在KV Cache Offload配置与调优中的实战应用,通过多级存储架构和智能卸载策略,显著降低大模型推理成本达84%。文章涵盖HiCache架构优势、环境配置、高级调优策略及生产环境最佳实践,帮助开发者优化GPU显存使用,提升并发处理能力。

weixin_29044713的博客 461

OpenGl学习之glRotate函数

glRotate NAME glRotated, glRotatef -- multiply the current matrix by a rotation matrix  将当前矩阵和一个旋转矩阵相乘。 C SPECIFICATION c语言说明 void glRotated(GLdouble angle,                GLdouble x,

轮子.exe 1万+

Sparse4Dv3

instance_feature也设置为nn.Parameter。修正分支2*(linear->relu->linear->relu->layernorm)->linear->scale,分类分枝2*(linear->relu->layernorm)->linear(256,9),质量评估分枝2*(linear->relu->layernorm)->linear(256,2)。每组两类instance,1是加上范围(-x,x)内均匀分布噪声,2是加上(-2x,-x)U(x,2x)范围内均匀分布噪声。

yuanl15的博客 1351

OpenGL ES之glScale函数

名称: glScale —— 将新的缩放矩阵乘以当前矩阵 函数原型: void glScalef(GLfloat x,  GLfloat y,  GLfloat z); void glScalex(GLfixed x,  GLfixed y,  GLfixed z); 函数参数: x, y, z   指明x, y, z 轴的缩放因子 描

飞鱼 8040

单目标跟踪算法及其复现过程---SiamFC(一)

在test.py文件中,就是利用训练出来的模型进行测试,需要更改预训练模型的路径,测试集的路径,以OTB100为例,最后输出的是对每一帧目标位置的坐标点。代码如下:首先需要下载got10k官方库,只需要在终端输入(注意:在终端安装各种库的时候不能使用网络代理),在环境已经配置到的情况下,只需要该其中的路径和就可以运行。这个系列博客仅为了记录各目标跟踪算法的复现(大多为跑通大佬们实现的代码),包括其中出现的很多问题和错误,学到的新知识等等。解决,而且只使用在线的方法,限制了他们可以学习的模型的丰富性。

weixin_58244117的博客 4761

S型速度曲线进阶:基于Sin²(x)的PLC平滑运动控制实践(以伺服/步进系统为例)

本文深入探讨了基于Sin²(x)的S型速度曲线在PLC平滑运动控制中的实践应用,特别针对伺服/步进系统。通过对比传统梯形曲线和七段S曲线,详细展示了Sin²(x)曲线在加速度连续性、计算效率和参数自适应性方面的优势,并结合博图平台的具体实现技巧和实战案例,为精密运动控制提供了优化方案。

weixin_28718793的博客 242

模型矩阵、视图矩阵、投影矩阵

模型视图投影矩阵的作用,就是将顶点从局部坐标系转化到规范立方体(Canonical View Volnme)中。总而言之,模型视图投影矩阵=投影矩阵×视图矩阵×模型矩阵,模型矩阵将顶点从局部坐标系转化到世界坐标系中,视图矩阵将顶点从世界坐标系转化到视图坐标系下,而投影矩阵将顶点从视图坐标系转化到规范立方体中。 如下图所示,假设现在要将三维空间中的三角形渲染到屏幕上。三角形的模型文件中,顶点坐标是

Jared_LAU的专栏 1万+

Telegram AI Bot自动化实战:5步用Make搭建业务工作台

Telegram Bot 是一种轻量级、高抵达率的消息自动化载体,其核心价值在于将结构化消息(如text、photo、callback_query)转化为可编程的事件流。基于 Bot API 的简洁设计与 Webhook 机制,开发者无需复杂鉴权即可实现毫秒级响应。结合低代码平台 Make,可快速构建具备上下文识别、条件路由、多系统分发与错误熔断能力的自动化流程。该方案特别适用于客服分发、数据同步、IoT告警等高频、规则明确、需即时反馈的业务场景,显著降低对 Python/Node.js 编程与 DevOp

weixin_33158887的博客 300

Opengl图形变换练习——矩形与圆变换合成小汽车

OpenGL中的变换: 平移:glTranslate3f(dx,dy,dz); 旋转:glRotate3f(angle, x, y, z); 缩放:glScale3f(sx, sy, sz); 练习内容: 在窗口中绘制一个圆形和矩形。 ; 再绘制一遍相同的圆和矩形,并作恰当的变换,使它们组合成一辆卡通汽车的形状。整个图形都显示在视图窗口内; #include <windows.h> #include <gl/glut.h> #include "math.h" int

八爪鱼的博客 1400

【Sentaurus TCAD仿真】几种基础操作

当内存不足时,没必要删除整个Project,只需要 Clean up 节点信息即可。因为占用内存的主要部分是。文件数据,Command文件是不占用多少内存的,下次需要此工程仿真结果重新运行即可。右击可以对该工程进行剪切、复制、删除、重命名等操作。当节点号有时候排序混乱的时候,我们需要重新编排节点号。此时左侧工具栏就能看见我们新建的这个工程。运行节点时不同的颜色代表目前的状态。在这个地方添加要使用的工具。这个时候需要的工具就建好了。然后选择需要使用的工具。我们需要保存这个工程。

qq_45746744的博客 1万+

BES2300x笔记(36) -- OTA升级

哈喽大家好,这是该系列博文的第三十六篇~ 篇~ <<【系列博文索引】快速通道 >> 一、前言 BES 蓝牙方案自带 OTA(Over The Air)功能,该功能可以对蓝牙固件进行在线升级,目前该功能支持通过安卓手机(苹果手机也有对应APP,未实际测试)对蓝牙固件进行升级,以后还会支持通过 PC 端进行在线升级。在使用 OTA 功能之前,用户需安装 BES 提供的手机 apk 软件,将需要升级的固件拷贝到手机,然后通过该 apk 软件进行在线升级。

文化人的博客 5356

opengl 视角问题

OpenGL变换实际上是通过矩阵乘法来实现。无论是移动、旋转还是缩放大小,都是通过在当前矩阵的基础上乘以一个新的矩阵来达到目的。关于矩阵的知识,这里不详细介绍,有兴趣的朋友可以看看线性代数(大学生的话多半应该学过的)。 OpenGL可以在最底层直接操作矩阵,不过作为初学,这样做的意义并不大。这里就不做介绍了。 1、模型变换和视图变换 从“相对移动”的观点来看,改变观察点的位置与方向和

xbl1986的专栏 9140

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

(二)OpenGL坐标平移、旋转与缩放

1.坐标平移:glTranslate void glTranslated(GLdouble x,Gldouble y, Gldouble z) void glTranslatef(GLfloat x,Glfloat y, Glfloat z)   参数说明:x,y,z 指定平移向量的x,y,z坐标,即将当前坐标系分别向x,y,z方向移动x,y,z个单位长度。   举例,将在原坐标系中画一个红色三角...

遥望星河的博客 5397

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

OpenGL之glMatrixMode函数的用法

函数原型:        void glMatrixMode(GLenum mode) 参数说明:     ...

deniece1的博客 1011

OpenGL模型变换和视图变换

从“相对移动”的观点来看,改变观察点的位置与方向和改变物体本身的位置与方向具有等效性。在OpenGL中,实现这两种功能甚至使用的是同样的函数。 由于模型和视图的变换都通过矩阵运算来实现,在进行变换前,应先设置当前操作的矩阵为“模型视图矩阵”。设置的方法是以GL_MODELVIEW为参数调用glMatrixMode函数,像这样: glMatrixMode(GL_MODELVIEW); 通常,我

u014538198的专栏 976

【OpenGL】计算机图形学实验五: 图形变换实验(二维、三维图形的变换)

(二维、三维图形的变换)1、实验目的和要求理解二维、三维图形变换的数学原理原理,并能利用OpenGL绘制简单的二维、三维图形,调用OpenGL命令实现基本的图形变换。2、实验设备PC机、CodeBlocks\VS系列\OpenGL安装包3、实验内容及原理 实验原理(基本知识)1) 键盘回调函数:glutKeyboardFunc(void(*func)(unsigned char key, int x, int y)); key表示键盘上按下的键,如’w’, ‘a’, ‘s’, ‘d’等。 2)

JKL27的博客 6429

ModelView矩阵各列含义及说明

在opengl中,视图和模型变换是在一个矩阵中进行控制的,这个矩阵就是GL_MODELVIEW_MATRIX,可以使用glGetFloatv函数来获取这个矩阵,而我们所要使用glTranslate*, glRotate*,glScale* 等操作均最后反映到这个矩阵的变化中,所以了解这个矩阵的构造对于灵活运用OpenGL比较重要。 变换矩阵在内存中的存放方式如下: m[0] m[4] m[ 8] m[12] m[1] m[5] m[ 9] m[13] m[2] m[6] m[10] m[14] m

danshiming的博客 903

OpenGL的视图变换

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33734785的博客 103

2、OpenGL - 坐标系

OpenGL - 坐标系 1、笛卡尔坐标 1.1、2D笛卡尔坐标系 平面坐标系,只有X 和 Y轴 1.2、3D笛卡尔坐标系 立体坐标系,有X Y轴还有Z 轴。形成立体3D图形 2、视口 在用户窗口中显示的大小,可以和原内容大小相同也可以不同 3、投影 光源的发出点称为 投影中心; 投影中心与物体上各点的连线称为 投影线; 接受投影的面,称为 投影面; 过物体上各点的投影线与投影面的交点称为这些点的投影。 投影分为 中心投影 和 平行投影 两大类。 ...

shengdaVolleyball的博客 997
上一篇: Window OpenGL 程序C++版本
下一篇: OpenGL中多边型网格化--环绕规则
ftkghost
博客等级 码龄22年 40粉丝 28原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值