Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Could anyone explain this math?

Recommended Posts

	vec3 i  = floor(v + dot(v, C.yyy));
	

v is a vector and add to a dot product of v and some other vector with y,y,y

the right part results in a scalar, how can a vector add to a scalar gives another vector?

	"vec4 permute(vec4 x) {",
            "return mod289(((x * 34.0) + 1.0) * x);",
        "}",
	

Also this, x of type vector4 is expanded 34 times should result in another vector4, how on earth can you add one to a vector4?

Update:

Does he mean to add one to a vector piecewise?

Thanks

Jack

Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement
1 hour ago, lucky6969b said:

the right part results in a scalar, how can a vector add to a scalar gives another vector?

While your thought is true in common mathematical understanding, it is just a question of definition for computer languages. In GLSL, for example, adding a scalar to a vector is possible; it just builds a vector where all components are set to the scalar and then performs a vector addition.

GLSL specification, chapter "Operators and Expressions", section "Expressions", says:

Quote

...
One operand is a scalar, and the other is a vector or matrix. In this case, the scalar operation is applied independently to each component of the vector or matrix, resulting in the same size vector or matrix.
...

 

Edited by haegarr

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!