-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shader-ast-stdlib): update cossin(), sincos(), add opt. scale fa…
…ctor arg
- Loading branch information
1 parent
7a20ae9
commit e3e8979
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
import type { FloatTerm } from "@thi.ng/shader-ast"; | ||
import { vec2 } from "@thi.ng/shader-ast/ast/lit"; | ||
import { mul } from "@thi.ng/shader-ast/ast/ops"; | ||
import { cos, sin } from "@thi.ng/shader-ast/builtin/math"; | ||
|
||
/** | ||
* Inline function. Returns vec2(sin(x), cos(x)). | ||
* Inline function. Returns vec2(sin(x), cos(x)), optionally scaled by `r` | ||
* | ||
* @param x - | ||
* @param r - | ||
*/ | ||
export const sincos = (x: FloatTerm) => vec2(sin(x), cos(x)); | ||
export const sincos = (x: FloatTerm, r?: FloatTerm | number) => { | ||
const res = vec2(sin(x), cos(x)); | ||
return r != undefined ? mul(res, r) : res; | ||
}; | ||
|
||
/** | ||
* Inline function. Returns vec2(cos(x), sin(x)). | ||
* Inline function. Returns vec2(cos(x), sin(x)), optionally scaled by `r`. | ||
* | ||
* @param x - | ||
* @param r - | ||
*/ | ||
export const cossin = (x: FloatTerm) => vec2(cos(x), sin(x)); | ||
export const cossin = (x: FloatTerm, r?: FloatTerm | number) => { | ||
const res = vec2(cos(x), sin(x)); | ||
return r != undefined ? mul(res, r) : res; | ||
}; |