보관물

7월, 2011에 대한 보관물

Mathematics v Direct3DX

7월 27, 2011 댓글 남기기

http://mormegil.wz.cz/prog/3dref/D3DXmath.htm

  • Vector
    • D3DXVecNAdd(Out, V1, V2)
    • D3DXVecNBaryCentric(Out, V1, V2, V3, f, g)
    • D3DXVecNCatmullRom(Out, V1, V2, V3, V4, s)
    • D3DXVecNDot(U, V)
    • D3DXVecNHermite(Out, V1, T1, V2, T2, s)
    • D3DXVecNLength(V)
    • D3DXVecNLengthSq(V)
    • D3DXVecNLerp(Out, V1, V2, s)
    • D3DXVecNMaximize(Out, U, V)
    • D3DXVecNMinimize(Out, U, V)
    • D3DXVecNNormalize(Out, V)
    • D3DXVecNScale(Out, V, s)
    • D3DXVecNSubtract(Out, V1, V2)
  • 2D Vector
    • D3DXVec2CCW(U, V)
    • D3DXVec2Transform(Out, V, M)
    • D3DXVec2TransformCoord(Out, V, M)
    • D3DXVec2TransformNormal(Out, V, M)
  • 3D Vector
    • D3DXVec3Cross(Out, V1, V2)
    • D3DXVec3Project(Out, V, Viewport, Proj, View, World)
    • D3DXVec3Transform(Out, V, M)
    • D3DXVec3TransformCoord(Out, V, M)
    • D3DXVec3TransformNormal(Out, V, M)
    • D3DXVec3Unproject(Out, V, Viewport, Proj, View, World)
  • 4D Vector
    • D3DXVec4Cross(Out, U, V, W)
    • D3DXVec4Transform(Out, V, M)
  • Matice (4×4)
    • D3DXMatrixAffineTransformation(Out, s, c, r, t)
    • D3DXMatrixfDeterminant(M)
    • D3DXMatrixIdentity(Out)
    • D3DXMatrixInverse(Out, D, M)
    • D3DXMatrixIsIdentity(M)
    • D3DXMatrixLookAtRH(Out, Eye, At, Up)
    • D3DXMatrixLookAtLH(Out, Eye, At, Up)
    • D3DXMatrixMultiply(Out, M1, M2)
    • D3DXMatrixOrthoRH(Out, w, h, n, f)
    • D3DXMatrixOrthoLH(Out, w, h, n, f)
    • D3DXMatrixOrthoOffCenterRH(Out, l, r, t, b, n, f)
    • D3DXMatrixOrthoOffCenterLH(Out, l, r, t, b, n, f)
    • D3DXMatrixPerspectiveRH(Out, w, h, n, f)
    • D3DXMatrixPerspectiveLH(Out, w, h, n, f)
    • D3DXMatrixPerspectiveFovRH(Out, Fovy, Aspect, n, f)
    • D3DXMatrixPerspectiveFovLH(Out, Fovy, Aspect, n, f)
    • D3DXMatrixPerspectiveOffCenterRH(Out, l, r, t, b, n, f)
    • D3DXMatrixPerspectiveOffCenterLH(Out, l, r, t, b, n, f)
    • D3DXMatrixReflect(Out, Plane)
    • D3DXMatrixRotationAxis(Out, V, Angle)
    • D3DXMatrixRotationQuaternion(Out, Q)
    • D3DXMatrixRotationX(Out, Angle)
    • D3DXMatrixRotationY(Out, Angle)
    • D3DXMatrixRotationYawPitchRoll(Out, Yaw, Pitch, Roll)
    • D3DXMatrixRotationZ(Out, Angle)
    • D3DXMatrixScaling(Out, x, y, z)
    • D3DXMatrixShadow(Out, Light, Plane)
    • D3DXMatrixTransformation(Out, Scenter, Srot, Scaling, Rotcenter, Rot, Trans)
    • D3DXMatrixTranslation(A, -Scenterx, -Scentery, -Scenterz)
    • D3DXMatrixScaling(B, Scalingx, Scalingy, Scalingz)
    • D3DXMatrixRotationQuaternion(C, Srot)
    • D3DXMatrixTranslation(D, ux, uy, uz)
    • D3DXMatrixRotationQuaternion(E, Rot)
    • D3DXMatrixTranslation(F, vx, vy, vz)
    • D3DXMatrixTranslation(Out, x, y, z)
    • D3DXMatrixTranspose(Out, M)
  • Planes
    • D3DXPlaneDot(P, V)
    • D3DXPlaneDotCoord(P, V)
    • D3DXPlaneDotNormal(P, V)
    • D3DXPlaneIntersectLine(Out, P, U, V)
    • D3DXPlaneFromPointNormal(Out, P, N)
    • D3DXPlaneNormalize(Out, P)
    • D3DXPlaneFromPoints(Out, A, B, C)
    • D3DXPlaneTransform(Out, P, M)
카테고리:3D, BiTec, Programming

Quatemion

7월 13, 2011 댓글 남기기

Quatemion
– 4차원 벡터
q = w + xi + yj + zk
= (w, x, y, z) = (w, v) = (s, v)

– 벡터 v가 회전축을 표현하지만 정규화 되면서 sin(theta/2)로 비례 축소
– 정규화된 쿼터니언에서 w가 회전각 theta를 표현
w = cos(theta / 2)
x = Axis.x * sin(theta / 2)
y = Axis.y * sin(theta / 2)
z = Axis.z * sin(theta / 2)

ex)
(0, 0, 1) PI / 4

w = cos(PI / 4) = sqrt2 / 2
x = 0sin(PI / 4) = 0
y = 0sin(PI / 4) = 0
z = 1sin(PI / 4) = sqrt2 / 2

특징
i^2 = j^2 = k^2 = -1
ij = -ji = k
jk – -kj = i
ki = -ik = j
ij – k
ji = -k

1) Q1 + Q2
= (w1, v1) + (w2, v2)
= (w1+w2, v1+v2)
2) Q1 * Q2
= (w1, v1) * (w2, v2)
= (w1, x1i, y1j, z1k) * (w2, x2i, y2j, z2k)
= (w1*w2 – w1*x2 – y1*y2 – z1*z2) +
(x1*w2 – w1*x2 – z1*y2 – y1*z2)i +
(y1*w2 – w1*y2 – z1*x2 – x1*z2)j +
(z1*w2 – w1*z2 – y1*x2 – x1*y2)k

= (w1*w2 – v1(내적)v2 + v1(외적)v2 + w1*v2 + w2*v1)

3)단위 사원수
q =
= 0i + 0j + 0k + 1

4)켤레사원수(Conjugate)
q = s+v, var q = s-v
q*var q = var q*q = q(내적)q = ||q||^2 = q^2

5)역수
0!=q, q^-1 = var q / q^2

6)변환
– Axis Angle to Quatemion
Q = (cos(theta/2), v*sin(theta/2))
– Quatemion to Axis Angle
Theta = 2 * acos(w)
회전축 = v / sin(theta/2)
– Quatemion to Matrix
F(p) = Q * P * Q^-1
= M * P
M = 1 – 2y^2 – 2z^2, 2xy-2zw, 2xz+2yw
2xy+2zw, 1-2x^2, 2yz-2xw
2xz-2yw, 2yz+2xw, 1-2x^2-2y^2
– 회전행렬 -> 사원수
R = (r00, r01…)
w = 1/2sqrt(R00+R11+R22+1)
x = 1/4w(R32-R12)
y = 1/4w(R02-R20)
z = 1/4w(R10-R01)

회전
F(p) = Q * P * Q^-1
여러회전(F1->F2)
F(p) = Q * P * Q^-1
F1(p) = Q1 * P * Q1^-1
F2(p) = Q2 * P * Q2^-1
= Q2 * (Q1*P*Q1^-1)*Q2-1
= (Q2Q1)P(Q2Q1)^-1
보간법
– 기본선형보간
Lerp(t) = (1-t)Q1 + tQ2
장점 : 간단, 매끄럽게 보간
단점 : t가 일정비율이 아님
3차원공간에서 x^2+y^2+z^2=1인 점이 모이면 원구면형성
4차원은 w^2+x^2+y^2+z^2=1
– 구형보간
theta = cos^-1(q1dotq2)
q(t) = (sin(theta)(1-t) / sin(theta)) * q1 + (sin(theta)(t) / sin(theta)) * q2
장점 : 일정비율
단점 : 복잡

카테고리:Programming

보간

7월 12, 2011 댓글 남기기

선형보간
– 두벡터들을 선형식으로 보간하여 현재위치에서 벡터를 계산
– 두점 사이의 최단 직선을 따라 동일한 속도로 이동하는 형태
– 두점이 사원수라면 단위 Hypersphere에 존재 단위 초구상을 따라 움직이는 두 사원수의 최단경로는
단위 Hypersphere에서의 두점을 잇는 원호가 된다.

구형선형보간
– 원호상에서의 등간격 보간
– 구 상에서는 동일한 회전에 해당하는 사원수가 2개씩 있어 보간시 경로가 가까운 쪽으로의 sphere를 선택하면 된다
– 짧은 경로를 선택하는 방법은 두 벡터를 내적하여 양수면 90미만이므로 짧은 경로인 것을 알수 있다.

선형보간과 구형선형보간의 차이
– 한 사원수에서 다른 사원수로 부드럽게 바꾸기 위해 t를 0에서 1로 바꾸면서 보간한다.
– 선형보간을 두 사원수를 잇는 직선을 일정간격으로 진행하면서 사원수를 보간하게 된다. 구형선형보간은 사원수를 원호를 일정간격으로 진행하면서 사원수를 보간하게 된다. 그래서 선형보간일 경우 직선상에서는 일정간격이지만 원호상에서는 움직임이 동일 간격이 아니며 두 점의 중점 지점에 가까울수록 이용하는 속도가 빨라지지만 구형선형보간은 그러한 일이 없이 일정한 속도로 움직인다.

카테고리:3D, BiTec

메모리 릭

7월 12, 2011 댓글 남기기

#ifndef _MEMORYLEAK_H_
#define _MEMORYLEAK_H_
 
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
static class MemoryMng
{
public:
    MemoryMng() 
    { 
        _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
               //_CrtSetBreakAlloc( 143 );
    }
    ~MemoryMng()
    { 
        _ASSERTE( _CrtCheckMemory( ) );
    }
 
 
} MemoryLeak;
#endif      // _DEBUG
#endif      // _MEMORYLEAK_H_

추가

중단점 설정 과 같이 쓰기

링크 : http://msdn.microsoft.com/ko-kr/library/w2fhc9a3.aspx

카테고리:Programming

Express-res

7월 12, 2011 댓글 남기기

AFXRES.7z
추가

카테고리:3D, Programming
팔로우

모든 새 글을 수신함으로 전달 받으세요.