优秀课件笔记之 Attributes of Graphics Primitives

本文介绍计算机图形学中图形原语的属性,包括状态系统、颜色模型、点线面属性及填充样式等,并探讨OpenGL中的实现方法。

1、本文所以内容来自 著名高校课件和学生笔记(校园里面经常见到有人高价买笔记)
2、任课教师不会提供参考文献,所以只能对作者表示感谢,如果引用了您的作品,可以用回复方式补充参考文献。
3、我不对文章无关问题进行解答,文章内容也比较难,我也很难解答您遇到的问题,如果发现BUG可以用回复方式帮我修正。
4、本课 属于Computer Graphics
,适用于计算机图形学课程,教材为电子工业出版社Computer Graphics(计算机图形学,中文版和英文版)
本课其他部分的导航条见页面底部

Chapter 4
Attributes of Graphics Primitives

State System and State Variables

A graphics system that maintain a list for the current values of attributes and parameters is called state system, or state machine.
Attributes of output primitives and some other parameters are called state variables or state parameters.

§4.1 OpenGL State Variables

OpenGL State Variables include:
Color and other primitives attributes
The current matrix mode
The elements of the model-view matrix
The current position for the frame buffer
The parameters for the lighting effects
Etc.

§4.2 Color and Grayscale

RGB color components
R, G, B components are mixed to display a particular color
Described with float numbers, the components ranged from 0.0 to 1.0
Described with integers, the components ranged from 0 to 255
Grayscale: only lighteness, without color
Described with float numbers, the lighteness ranged from 0.0 to 1.0
Described with integers, the lighteness ranged from 0 to 255

§4.3 OpenGL Color Functions

Set the color display mode:

glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA);

Select the current color:
glColor3f (0.0, 1.0, 1.0);
glColor3i (255, 255, 0);
glColor3fv (colorArray);


RGBA Color Model
In RGBA color model, A is alpha coefficient.
The alpha coefficient controls color blending(颜色调和) for overlapping primitives.
Color blending is used in the simulation of transparency(透明) .

OpenGL Color Blending
To enable and disable color blending:
glEnable (GL_BLEND);
glDisable (GL_BLEND);

§4.4 Point Attributes in OpenGL

In OpenGL, a point has two attributes:
Size and color
To set the size of a point in OpenGL:
glPointSize(size);
To set the color of a point in OpenGL:
glColor3f (1.0, 0.0, 0.0);
glBegin (GL_POINTS);
glVertex2i (50,100);
glPointSize (2.0);
glEnd ( );

§4.5 Line Attributes in OpenGL

In OpenGL, a line has three attributes in general:
Width, style and color

To set the width of a line in OpenGL:

glLineWidth(width);
To set the color of a line in OpenGL, like to set the color of other primitives.

glColor3f (1.0, 0.0, 0.0);
glBegin (GL_LINES);
glVertex2iv (p1);
……
glEnd ( );

To Set Line-Style in OpenGL

To enable and disable line-style function:

glEnable (GL_LINE_STIPPLE);
glDisable (GL_LINE_STIPPLE);
To set the line-style:
glLineStipple (repeatFactor, pattern);
pattern is a 16-bit integer to describe the line-style:
§4.6 Curve Attributes

Parameters of curve attributes are the same as those for straight-line segments.

§4.9 Fill-Area Attributes

Scan-line approach:
Usually used in simple shapes
General graphics packages use this method
Use a starting interior point:
Usually used in complex shapes or interactive systems
Fill Styles

A basic fill-area attribute provided by a general graphics library is the display style of the interior.
We can display a region with
a hollow style
a single color
a specified fill pattern
§4.14 OpenGL Fill-Area Functions

We generate displays of filled convex polygons(凸多边形) in 4 steps:
Define a fill pattern;

Invoke the polygon-fill routine;

Activate the polygon-fill feature of OpenGL;

Describe the polygons to be filled.


GLubyte fillPattern []= {0xff, 0x00, ……};

glPolygonStripple (fillPattern);

glEnable(GL_POLYGON_STIPPLE);

OpenGL Interpolation(插值) Patterns

glShapeModel(GL_SMOOTH);
// GL_SMOOTH means smooth transition(过渡) effect
glBegin(GL_TRANGLES)
glColor(1.0, 0.0, 0.0);
glVertex2i(50,50);
glColor(0.0, 0.0, 1.0);
glVertex2i(0, 0);
glVertex2i(75, 0);
glEnd();
OpenGL Wire-Frame Methods

When the edges and interior area of a same polygon have different colors, we can:
glPolygonModel(GL_FRONT, GL_FILL);
glColor3f(1.0, 0.0, 0.0);
// Invoke polygon-generating routines

glPolygonModel(GL_FRONT, GL_LINE);
glColor3f(0.0, 1.0, 0.0);
// Invoke polygon-generating routines
§4.17 Anti-aliasing (反走样)

Graphics primitives have a jagged(锯齿状) appearance because of the low-frequent sampling(低频采样).
This is called aliasing (走样).
Methods that can eliminate aliasing is called anti-aliasing (反走样).
One is super-sample(过采样).
§4.18 OpenGL Anti-aliasing (反走样) Functions

glEnable (primitiveType);
// primitiveType can be GL_POINT_SMOOTH,
// GL_LINE_SMOOTH, GL_POLYGON_SMOOTH

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Color blending
§4.19 OpenGL Query Functions

Using OpenGL Query Functions, we can get current values for any state parameters.
glGet functions:
Each function needs two parameters:
glGetBooleanv(...);
glGetFloatv(...);
glGetIntegerv(...);
glGetFloatv(GL_CURRENT_COLOR, colorValues);
// The first parameter means what to be queried;
// The second parameter store the queried result.

MATLAB主动噪声和振动控制算法——对较大的次级路径变化具有鲁棒性内容概要:本文主要介绍了一种在MATLAB环境下实现的主动噪声和振动控制算法,该算法针对较大的次级路径变化具有较强的鲁棒性。文中详细阐述了算法的设计原理与实现方法,重点解决了传统控制系统中因次级路径动态变化导致性能下降的问题。通过引入自适应机制和鲁棒控制策略,提升了系统在复杂环境下的稳定性和控制精度,适用于需要高精度噪声与振动抑制的实际工程场景。此外,文档还列举了多个MATLAB仿真实例及相关科研技术服务内容,涵盖信号处理、智能优化、机器学习等多个交叉领域。; 适合人群:具备一定MATLAB编程基础和控制系统理论知识的科研人员及工程技术人员,尤其适合从事噪声与振动控制、信号处理、自动化等相关领域的研究生和工程师。; 使用场景及目标:①应用于汽车、航空航天、精密仪器等对噪声和振动敏感的工业领域;②用于提升现有主动控制系统对参数变化的适应能力;③为相关科研项目提供算法验证与仿真平台支持; 阅读建议:建议读者结合提供的MATLAB代码进行仿真实验,深入理解算法在不同次级路径条件下的响应特性,并可通过调整控制参数进一步探究其鲁棒性边界。同时可参考文档中列出的相关技术案例拓展应用场景。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值