mirror of
https://github.com/reactos/wine.git
synced 2025-03-01 09:16:00 +00:00
120 lines
2.6 KiB
C
120 lines
2.6 KiB
C
![]() |
/*
|
||
|
* Copyright 2007 David Adam
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Lesser General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2.1 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public
|
||
|
* License along with this library; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||
|
*/
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <stdarg.h>
|
||
|
#include <assert.h>
|
||
|
#include "windef.h"
|
||
|
#include "winbase.h"
|
||
|
#include "wingdi.h"
|
||
|
#include "d3dx8.h"
|
||
|
|
||
|
#include "wine/debug.h"
|
||
|
|
||
|
WINE_DEFAULT_DEBUG_CHANNEL(d3dx8);
|
||
|
|
||
|
/*_________________D3DXQUATERNION________________*/
|
||
|
|
||
|
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq)
|
||
|
{
|
||
|
FLOAT norm;
|
||
|
|
||
|
norm = D3DXQuaternionLength(pq);
|
||
|
if ( !norm )
|
||
|
{
|
||
|
pout->x = 0.0f;
|
||
|
pout->y = 0.0f;
|
||
|
pout->z = 0.0f;
|
||
|
pout->w = 0.0f;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
pout->x = pq->x / norm;
|
||
|
pout->y = pq->y / norm;
|
||
|
pout->z = pq->z / norm;
|
||
|
pout->w = pq->w / norm;
|
||
|
}
|
||
|
return pout;
|
||
|
}
|
||
|
/*_________________D3DXVec2_____________________*/
|
||
|
|
||
|
D3DXVECTOR2* WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv)
|
||
|
{
|
||
|
FLOAT norm;
|
||
|
|
||
|
norm = D3DXVec2Length(pv);
|
||
|
if ( !norm )
|
||
|
{
|
||
|
pout->x = 0.0f;
|
||
|
pout->y = 0.0f;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
pout->x = pv->x / norm;
|
||
|
pout->y = pv->y / norm;
|
||
|
}
|
||
|
return pout;
|
||
|
}
|
||
|
|
||
|
/*_________________D3DXVec3_____________________*/
|
||
|
|
||
|
D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv)
|
||
|
{
|
||
|
FLOAT norm;
|
||
|
|
||
|
norm = D3DXVec3Length(pv);
|
||
|
if ( !norm )
|
||
|
{
|
||
|
pout->x = 0.0f;
|
||
|
pout->y = 0.0f;
|
||
|
pout->z = 0.0f;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
pout->x = pv->x / norm;
|
||
|
pout->y = pv->y / norm;
|
||
|
pout->z = pv->z / norm;
|
||
|
}
|
||
|
return pout;
|
||
|
}
|
||
|
|
||
|
/*_________________D3DXVec4_____________________*/
|
||
|
|
||
|
D3DXVECTOR4* WINAPI D3DXVec4Normalize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv)
|
||
|
{
|
||
|
FLOAT norm;
|
||
|
|
||
|
norm = D3DXVec4Length(pv);
|
||
|
if ( !norm )
|
||
|
{
|
||
|
pout->x = 0.0f;
|
||
|
pout->y = 0.0f;
|
||
|
pout->z = 0.0f;
|
||
|
pout->w = 0.0f;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
pout->x = pv->x / norm;
|
||
|
pout->y = pv->y / norm;
|
||
|
pout->z = pv->z / norm;
|
||
|
pout->w = pv->w / norm;
|
||
|
}
|
||
|
return pout;
|
||
|
}
|