Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

accessing vector elements by swizzling

Boost , ,

Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

QVM: Quaternions, Vectors, Matrices

Accessing Vector Elements by Swizzling

#include <boost/qvm/swizzle.hpp>[ORIG_END] -->

namespace boost
{
    namespace qvm
    {
        //*** Accessing vector elements by swizzling ***
        
        //2D view proxies, only enabled if:
        //  is_vec<V>::value
        template <class V> -unspecified-2D-vector-type- XX( V & v );
        template <class V> -unspecified-2D-vector-type- XY( V & v );
        template <class V> -unspecified-2D-vector-type- XZ( V & v );
        template <class V> -unspecified-2D-vector-type- XW( V & v );
        template <class V> -unspecified-2D-vector-type- X0( V & v );
        template <class V> -unspecified-2D-vector-type- X1( V & v );
        template <class V> -unspecified-2D-vector-type- YX( V & v );
        template <class V> -unspecified-2D-vector-type- YY( V & v );
        template <class V> -unspecified-2D-vector-type- YZ( V & v );
        template <class V> -unspecified-2D-vector-type- YW( V & v );
        template <class V> -unspecified-2D-vector-type- Y0( V & v );
        template <class V> -unspecified-2D-vector-type- Y1( V & v );
        template <class V> -unspecified-2D-vector-type- ZX( V & v );
        template <class V> -unspecified-2D-vector-type- ZY( V & v );
        template <class V> -unspecified-2D-vector-type- ZZ( V & v );
        template <class V> -unspecified-2D-vector-type- ZW( V & v );
        template <class V> -unspecified-2D-vector-type- Z0( V & v );
        template <class V> -unspecified-2D-vector-type- Z1( V & v );
        template <class V> -unspecified-2D-vector-type- WX( V & v );
        template <class V> -unspecified-2D-vector-type- WY( V & v );
        template <class V> -unspecified-2D-vector-type- WZ( V & v );
        template <class V> -unspecified-2D-vector-type- WW( V & v );
        template <class V> -unspecified-2D-vector-type- W0( V & v );
        template <class V> -unspecified-2D-vector-type- W1( V & v );
        ...
        -unspecified-2D-vector-type- _00();
        -unspecified-2D-vector-type- _01();
        -unspecified-2D-vector-type- _10();
        -unspecified-2D-vector-type- _11();
        
        //3D view proxies, only enabled if:
        //  is_vec<V>::value
        template <class V> -unspecified-3D-vector-type- XXX( V & v );
        ...
        template <class V> -unspecified-3D-vector-type- XXW( V & v );
        template <class V> -unspecified-3D-vector-type- XX0( V & v );
        template <class V> -unspecified-3D-vector-type- XX1( V & v );
        template <class V> -unspecified-3D-vector-type- XYX( V & v );
        ...
        template <class V> -unspecified-3D-vector-type- XY1( V & v );
        ...
        template <class V> -unspecified-3D-vector-type- WW1( V & v );
        ...
        -unspecified-3D-vector-type- _000();
        -unspecified-3D-vector-type- _001();
        -unspecified-3D-vector-type- _010();
        ...
        -unspecified-3D-vector-type- _111();
        
        //4D view proxies, only enabled if:
        //  is_vec<V>::value
        template <class V> -unspecified-4D-vector-type- XXXX( V & v );
        ...
        template <class V> -unspecified-4D-vector-type- XXXW( V & v );
        template <class V> -unspecified-4D-vector-type- XXX0( V & v );
        template <class V> -unspecified-4D-vector-type- XXX1( V & v );
        template <class V> -unspecified-4D-vector-type- XXYX( V & v );
        ...
        template <class V> -unspecified-4D-vector-type- XXY1( V & v );
        ...
        template <class V> -unspecified-4D-vector-type- WWW1( V & v );
        ...
        -unspecified-4D-vector-type- _0000();
        -unspecified-4D-vector-type- _0001();
        -unspecified-4D-vector-type- _0010();
        ...
        -unspecified-4D-vector-type- _1111();         
    }
}

Swizzling обеспечивает прямой доступ к подмножеству элементов 2D, 3D и 4D векторов с нулевыми накладными расходами. Например, еслиvявляется 4D-вектором, выражение(v,YX)представляет собой 2Dвид прокси, чейXэлемент относится кYэлементv, и чейYэлемент относится кXэлементv. Как и другиепроксиYXявляется lvalue, то есть, еслиv2является 2D-вектором, можно написать:

YX(v) = v2;

Вышеуказанные элементыZиWvне изменяются, но придаютYэлементv2XэлементvиXэлементv2Yэлементv.

Также возможно повторение одного и того же векторного элемента при взмахе rvalue: выражениеZZZ(v)является 3D-вектором, чьиX,YиZэлементы относятся кZэлементv.

Статья accessing vector elements by swizzling раздела может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-19 21:39:53/0.027660846710205/1