-
-
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(geom): add/update rotate, scale, translate, transform ops (signa…
…tures & type support, impls)
- Loading branch information
1 parent
1cefc37
commit cb04a96
Showing
8 changed files
with
260 additions
and
124 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,11 +1,24 @@ | ||
import type { PCLike, PCLikeConstructor } from "@thi.ng/geom-api"; | ||
import type { ReadonlyVec } from "@thi.ng/vectors"; | ||
import { rotate } from "@thi.ng/vectors/rotate"; | ||
import { rotateAroundAxis3 } from "@thi.ng/vectors/rotate-around-axis"; | ||
import { __copyAttribs } from "./copy.js"; | ||
|
||
export const __rotatedPoints = (pts: ReadonlyVec[], delta: number) => | ||
pts.map((x) => rotate([], x, delta)); | ||
export const __rotatedPoints = (pts: ReadonlyVec[], theta: number) => | ||
pts.map((x) => rotate([], x, theta)); | ||
|
||
export const __rotatedPoints3 = ( | ||
pts: ReadonlyVec[], | ||
axis: ReadonlyVec, | ||
theta: number | ||
) => pts.map((x) => rotateAroundAxis3([], x, axis, theta)); | ||
|
||
export const __rotatedShape = | ||
(ctor: PCLikeConstructor) => ($: PCLike, delta: number) => | ||
new ctor(__rotatedPoints($.points, delta), __copyAttribs($)); | ||
<T extends PCLike>(ctor: PCLikeConstructor<T>) => | ||
($: T, theta: number) => | ||
<T>new ctor(__rotatedPoints($.points, theta), __copyAttribs($)); | ||
|
||
export const __rotatedShape3 = | ||
<T extends PCLike>(ctor: PCLikeConstructor<T>) => | ||
($: T, axis: ReadonlyVec, theta: number) => | ||
<T>new ctor(__rotatedPoints3($.points, axis, theta), __copyAttribs($)); |
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
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
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
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
Oops, something went wrong.