# Matrices

**URL:** <https://forum.kirupa.com/t/matrices/187495>\
**Category:** Uncategorized\
**Created:** [April 29, 2006, 7:18pm UTC](https://forum.kirupa.com/t/matrices/187495 "2006-04-29T19:18:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torq](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/torq/32/2378_2.png) [@Torq](https://forum.kirupa.com/u/Torq)\
**Post date:** [April 29, 2006, 7:18pm UTC](https://forum.kirupa.com/t/matrices/187495/1 "2006-04-29T19:18:23Z")

</div>

Hey, could someone please help me, I’m getting a little overwhelmed with vector and matrix math that I have no idea what does what anymore. I’m trying to take a 3D coord and rotate it around the x axis. Sounds easy enough, but what I don’t get is how you get the coord from the matrix.

I wasn’t clearing (identity) the matrix before, so I figured I could just keep rotating the values in the matrix, but it doesn’t seem to work?

So, couldn’t I just clear my matrix (identity), set the matrix x/y/z to my coords (translate), then rotate, and return the vector? Would this work? What do I need to change?

```
 ActionScript Code:
 [FONT=Courier New][LEFT]::m_Coords is a CVector

```

::m\_Orient is a CMatrix

```
[COLOR=#808080]*//CCamera.a*[/COLOR]
[COLOR=#0000ff]public[/COLOR] [COLOR=#000000] **function** [/COLOR] RotateX[COLOR=#000000]([/COLOR]angle:[COLOR=#0000ff]Number[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000ff]Void[/COLOR]
[COLOR=#000000]{[/COLOR]
    m_Orient.[COLOR=#000080]Identity[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    m_Orient.[COLOR=#000080]Translate[/COLOR][COLOR=#000000]([/COLOR]m_Coords.[COLOR=#000080]x[/COLOR], m_Coords.[COLOR=#000080]y[/COLOR], m_Coords.[COLOR=#000080]z[/COLOR][COLOR=#000000])[/COLOR];
   
    [COLOR=#000000] **var** [/COLOR] vec:CVector = m_Orient.[COLOR=#000080]RotateX[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000080]60[/COLOR][COLOR=#000000])[/COLOR];
    m_Coords.[COLOR=#000080]y[/COLOR] = vec.[COLOR=#000080]y[/COLOR];
    m_Coords.[COLOR=#000080]z[/COLOR] = vec.[COLOR=#000080]z[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]*//CMatrix.*[/COLOR]
[COLOR=#0000ff]public[/COLOR] [COLOR=#000000] **function** [/COLOR] RotateX[COLOR=#000000]([/COLOR]angle:[COLOR=#0000ff]Number[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000ff]Void[/COLOR]
[COLOR=#000000]{[/COLOR]
    angle *= DEG2RAD;
    
    [COLOR=#000000] **var** [/COLOR] [COLOR=#0000ff]cos[/COLOR]:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]cos[/COLOR][COLOR=#000000]([/COLOR]angle[COLOR=#000000])[/COLOR];
    [COLOR=#000000] **var** [/COLOR] [COLOR=#0000ff]sin[/COLOR]:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]sin[/COLOR][COLOR=#000000]([/COLOR]angle[COLOR=#000000])[/COLOR];
    
    m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR] *= [COLOR=#0000ff]cos[/COLOR]; m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR] *= -[COLOR=#0000ff]sin[/COLOR];
    m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR] *= [COLOR=#0000ff]sin[/COLOR]; m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR] *= [COLOR=#0000ff]cos[/COLOR];
    
    [COLOR=#000000] **var** [/COLOR] x2:[COLOR=#0000ff]Number[/COLOR] = m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR];
    [COLOR=#000000] **var** [/COLOR] y2:[COLOR=#0000ff]Number[/COLOR] = m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR] + m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR] + m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR] + m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]3[/COLOR][COLOR=#000000]][/COLOR];
    [COLOR=#000000] **var** [/COLOR] z2:[COLOR=#0000ff]Number[/COLOR] = m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR] + m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR] + m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR] + m_Data[COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]3[/COLOR][COLOR=#000000]][/COLOR];
    
    [COLOR=#0000ff]return[/COLOR] [COLOR=#000000] **new** [/COLOR] CVector[COLOR=#000000]([/COLOR]x2, y2, z2[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]

```

[/LEFT]  
[/FONT]

I’ve been reading alot of resources, so I don’t need any more unless they are great ones. The problem is I’m running into a variety of methods.

Thanks for any help.
