请输入您要查询的百科知识:

 

词条 Wrapping (graphics)
释义

  1. Implementation

  2. See also

{{About|the technique used in 3D graphics|wrapping in word processing|Word wrap}}{{multiple issues|{{Unreferenced|date=December 2009}}{{context|date=June 2017}}
}}

In computer graphics, wrapping is the process of limiting a position to an area. A good example of wrapping is wallpaper, a single pattern repeated indefinitely over a wall. Wrapping is used in 3D computer graphics to repeat a texture over a polygon, eliminating the need for large textures or multiple polygons.

To wrap a position x to an area of width w, calculate the value .

Implementation

For computational purposes the wrapped value x' of x can be expressed as

where is the highest value in the range, and is the lowest value in the range.

Pseudocode for wrapping of a value to a range other than 0-1 is

  '''function''' wrap(X, Min, Max: Real): Real;    X := X - Int((X - Min) / (Max - Min)) * (Max - Min);    '''if''' X < 0 '''then''' //This corrects the problem caused by using Int instead of Floor      X := X + Max - Min;    '''return''' X;

Pseudocode for wrapping of a value to a range of 0-1 is

  '''function''' wrap(X: Real): Real;    X := X - Int(X);    '''if''' X < 0 '''then'''      X := X + 1;    '''return''' X;

Pseudocode for wrapping of a value to a range of 0-1 without branching is,

  '''function''' wrap(X: Real): Real;    '''return''' ((X mod 1.0) + 1.0) mod 1.0;

See also

  • Clamping
{{DEFAULTSORT:Wrapping (Graphics)}}

1 : Computer graphics algorithms

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/18 15:57:37