Results 1 to 2 of 2

Thread: vec3(vec4(vertex, 1));?????

  1. #1
    Member Newbie
    Join Date
    Sep 2014
    Posts
    33

    vec3(vec4(vertex, 1));?????

    can i do vec3( matrixrotation * vec4(vertex, 1)); to get a vec3? matrixrotation is a 4x4 matrix. thanks

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,112
    Quote Originally Posted by a-sylum View Post
    can i do vec3( matrixrotation * vec4(vertex, 1)); to get a vec3? matrixrotation is a 4x4 matrix. thanks
    Yes. For a rotation, you can also use mat3x3(matrixrotation) * vertex. But that's only equivalent if the matrix has no translation component.

    If you want to specifically ignore the translation component (e..g. if you're transforming a direction rather than a position), you can use the mat3x3() approach or set the fourth component of the vector to zero rather than one.

Similar Threads

  1. Replies: 1
    Last Post: 11-17-2016, 07:52 AM
  2. Replies: 2
    Last Post: 12-25-2013, 10:05 AM
  3. Replies: 1
    Last Post: 06-02-2012, 05:26 AM
  4. vec3 worldCoord(vec3 ); window to world FragCoord
    By Red_Riot in forum OpenGL: General
    Replies: 12
    Last Post: 03-20-2011, 11:31 PM
  5. vec4 = mat4 + vec4
    By imported_Groovounet in forum OpenGL: GLSL
    Replies: 3
    Last Post: 08-06-2006, 05:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean