# 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 on other sites
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

## Create an account

Register a new account

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633338
• Total Posts
3011419
• ### Who's Online (See full list)

There are no registered users currently online

×