-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
209 changed files
with
71,880 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## 2021-2022 计算机图形学 大三上学期 回忆版 | ||
|
||
#### 选择题(10分,2*5分) | ||
|
||
* bresenham没有优化什么运算(选项为浮点除法、浮点乘法、浮点开方、最后一个选项忘了,这个题应该是选浮点开方) | ||
* 透视投影中最多有多少个主灭点(网上应该能搜到) | ||
* 光线追踪算法哪一步运算最复杂(祖传题,答案应该是求交) | ||
* 十六进制颜色0x000000是什么颜色(黑色) | ||
* 圆柱表示,给了x=cos(2πu),z=v/h,让你选y=什么(应该是sin(2πu)) | ||
|
||
#### 大题(7个,前面3x10分,后面4x15分) | ||
|
||
* 扫描线填充算法写伪码 | ||
|
||
* 面消隐算法有哪些?(6种) | ||
|
||
* phong光照模型(图示+讲解)并解释各个量的含义,表示出反射方向单位向量R | ||
|
||
* 求三维空间内一个给定三角形和给定正方形有没有交集,如果有,给出交线段 | ||
|
||
* 齐次矩阵变换 | ||
|
||
* (x,y)关于y=x的对称点是什么?用3x3的齐次变换矩阵表示 | ||
* (x,y)关于y轴的对称点是什么?用3x3的齐次变换矩阵表示 | ||
* (x,y)先关于y=x对称,再关于y轴对称,写出复合变换矩阵(前两个乘一下,先变换的在右边) | ||
|
||
* 曲线,给四个点 | ||
|
||
* 这四个点作为控制点的bezier曲线是什么? | ||
* 将上面的bezier曲线转换为均匀B样条,对应的四个控制点是什么(书上有) | ||
* 如果把bezier转换为三次hermite曲线,对应的端点位置和端矢分别是什么? | ||
|
||
* 透视变换祖传题,稍微改了一下。投影面是xoz面 | ||
|
||
* 祖传题大体是这样的: | ||
|
||
``` | ||
假定视点(投影中心)位置为 (0,-2,0),沿y轴正方向投影,投影面与y轴垂直并经过点 (0,1,0)。(15分;答案直接写在卷面上) | ||
(a) 请写出点 (2, 2, 2) 经过透视投影后的坐标。 | ||
(b) 请写出投影矩阵。 | ||
``` | ||
|
||
* 第一问画出透视投影图(投影到xoy、zoy平面) | ||
|
||
* 第二问求(2,4,6)经透视投影后的坐标 | ||
|
||
* 第三问写出投影矩阵 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
// | ||
// Created by pacer on 2019/6/19. | ||
// | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
///////////////////////////////////////////////////ArcBall.cpp//////////////////////////////////////////////////////// | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
//#include <windows.h> | ||
#include <GL/glut.h> | ||
|
||
#include <math.h> | ||
#include "arcball.h" | ||
|
||
//轨迹球参数: | ||
//直径 2.0f | ||
//半径 1.0f | ||
//半径平方 1.0f | ||
|
||
|
||
void ArcBall_t::_mapToSphere(const Point2fT* NewPt, Vector3fT* NewVec) const | ||
{ | ||
Point2fT TempPt; | ||
GLfloat length; | ||
|
||
//复制到临时变量 | ||
TempPt = *NewPt; | ||
|
||
//把长宽调整到[-1 ... 1]区间 | ||
TempPt.s.X = (TempPt.s.X * this->AdjustWidth) - 1.0f; | ||
TempPt.s.Y = 1.0f - (TempPt.s.Y * this->AdjustHeight); | ||
|
||
//计算长度的平方 | ||
length = (TempPt.s.X * TempPt.s.X) + (TempPt.s.Y * TempPt.s.Y); | ||
|
||
//如果点映射到球的外面 | ||
if (length > 1.0f) | ||
{ | ||
GLfloat norm; | ||
|
||
//缩放到球上 | ||
norm = 1.0f / FuncSqrt(length); | ||
|
||
//设置z坐标为0 | ||
NewVec->s.X = TempPt.s.X * norm; | ||
NewVec->s.Y = TempPt.s.Y * norm; | ||
NewVec->s.Z = 0.0f; | ||
} | ||
//如果在球内 | ||
else | ||
{ | ||
//利用半径的平方为1,求出z坐标 | ||
NewVec->s.X = TempPt.s.X; | ||
NewVec->s.Y = TempPt.s.Y; | ||
NewVec->s.Z = FuncSqrt(1.0f - length); | ||
} | ||
} | ||
|
||
ArcBall_t::ArcBall_t(GLfloat NewWidth, GLfloat NewHeight) | ||
{ | ||
this->StVec.s.X =0.0f; | ||
this->StVec.s.Y = 0.0f; | ||
this->StVec.s.Z = 0.0f; | ||
|
||
this->EnVec.s.X =0.0f; | ||
this->EnVec.s.Y = 0.0f; | ||
this->EnVec.s.Z = 0.0f; | ||
|
||
|
||
Matrix4fSetIdentity(&Transform); | ||
Matrix3fSetIdentity(&LastRot); | ||
Matrix3fSetIdentity(&ThisRot); | ||
|
||
this->isDragging=false; | ||
this->isClicked= false; | ||
this->isRClicked = false; | ||
this->isZooming = false; | ||
this->zoomRate = 1; | ||
this->setBounds(NewWidth, NewHeight); | ||
} | ||
|
||
//新加的 | ||
void ArcBall_t::upstate() | ||
{ | ||
if(!this->isZooming && this->isRClicked){ // 开始拖动 | ||
this->isZooming = true; // 设置拖动为变量为true | ||
this->LastPt = this->MousePt; | ||
this->lastZoomRate = this->zoomRate; | ||
} | ||
else if(this->isZooming){//正在拖动 | ||
if(this->isRClicked){ //拖动 | ||
Point2fSub(&this->MousePt, &this->LastPt); | ||
this->zoomRate = this->lastZoomRate + this->MousePt.s.X * this->AdjustWidth * 2; | ||
} | ||
else{ //停止拖动 | ||
this->isZooming = false; | ||
} | ||
} | ||
else if (!this->isDragging && this->isClicked){ // 如果没有拖动 | ||
this->isDragging = true; // 设置拖动为变量为true | ||
this->LastRot = this->ThisRot; | ||
this->click(&this->MousePt); | ||
} | ||
else if(this->isDragging){ | ||
if (this->isClicked){ //如果按住拖动 | ||
Quat4fT ThisQuat; | ||
|
||
this->drag(&this->MousePt, &ThisQuat); // 更新轨迹球的变量 | ||
Matrix3fSetRotationFromQuat4f(&this->ThisRot, &ThisQuat); // 计算旋转量 | ||
Matrix3fMulMatrix3f(&this->ThisRot, &this->LastRot); | ||
Matrix4fSetRotationFromMatrix3f(&this->Transform, &this->ThisRot); | ||
} | ||
else // 如果放开鼠标,设置拖动为false | ||
this->isDragging = false; | ||
} | ||
} | ||
/* | ||
void ArcBall_t::mousemove(WPARAM wParam,LPARAM lParam) | ||
{ | ||
this->MousePt.s.X = (GLfloat)LOWORD(lParam); | ||
this->MousePt.s.Y = (GLfloat)HIWORD(lParam); | ||
this->isClicked = (LOWORD(wParam) & MK_LBUTTON) ? true : false; | ||
this->isRClicked = (LOWORD(wParam) & MK_RBUTTON) ? true : false; | ||
} | ||
*/ | ||
//按下鼠标,记录当前对应的轨迹球的位置 | ||
void ArcBall_t::click(const Point2fT* NewPt) | ||
{ | ||
this->_mapToSphere(NewPt, &this->StVec); | ||
} | ||
|
||
//鼠标拖动,计算旋转四元数 | ||
void ArcBall_t::drag(const Point2fT* NewPt, Quat4fT* NewRot) | ||
{ | ||
//新的位置 | ||
this->_mapToSphere(NewPt, &this->EnVec); | ||
|
||
//计算旋转 | ||
if (NewRot) | ||
{ | ||
Vector3fT Perp; | ||
|
||
//计算旋转轴 | ||
Vector3fCross(&Perp, &this->StVec, &this->EnVec); | ||
|
||
//如果不为0 | ||
if (Vector3fLength(&Perp) > Epsilon) | ||
{ | ||
//记录旋转轴 | ||
NewRot->s.X = Perp.s.X; | ||
NewRot->s.Y = Perp.s.Y; | ||
NewRot->s.Z = Perp.s.Z; | ||
//在四元数中,w=cos(a/2),a为旋转的角度 | ||
NewRot->s.W= Vector3fDot(&this->StVec, &this->EnVec); | ||
} | ||
//是0,说明没有旋转 | ||
else | ||
{ | ||
NewRot->s.X = | ||
NewRot->s.Y = | ||
NewRot->s.Z = | ||
NewRot->s.W = 0.0f; | ||
} | ||
} | ||
} |
Oops, something went wrong.