-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add ParametrizedCurve * include file * add docstring * format * remove underscores in names * use minimum and maximum * fix * interval ab as optional argument * format * move include * Apply suggestions from code review Co-authored-by: Júlio Hoffimann <julio.hoffimann@gmail.com> * restructure range * Apply suggestions from code review Co-authored-by: Júlio Hoffimann <julio.hoffimann@gmail.com> * promote range * Update src/geometries/primitives/parametrizedcurve.jl * Update src/geometries/primitives/parametrizedcurve.jl * Update src/geometries/primitives/parametrizedcurve.jl Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> * add docs * Update src/geometries/primitives/parametrizedcurve.jl Co-authored-by: Júlio Hoffimann <julio.hoffimann@gmail.com> * remove newline * fix Float32 tests * add predicates test * add crs test * add sampling test * add discretization tests * format * use cart and merc consistently * Apply suggestions from code review Co-authored-by: Júlio Hoffimann <julio.hoffimann@gmail.com> * Update src/geometries/primitives/parametrizedcurve.jl Co-authored-by: Elias Carvalho <73039601+eliascarv@users.noreply.github.com> * func -> fun --------- Co-authored-by: Júlio Hoffimann <julio.hoffimann@gmail.com> Co-authored-by: Elias Carvalho <73039601+eliascarv@users.noreply.github.com>
- Loading branch information
1 parent
994b30a
commit fe86b2e
Showing
13 changed files
with
119 additions
and
0 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
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 |
---|---|---|
|
@@ -157,6 +157,7 @@ export | |
Ray, | ||
Line, | ||
BezierCurve, | ||
ParametrizedCurve, | ||
Plane, | ||
Box, | ||
Ball, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# ------------------------------------------------------------------ | ||
# Licensed under the MIT License. See LICENSE in the project root. | ||
# ------------------------------------------------------------------ | ||
|
||
""" | ||
ParametrizedCurve(fun, range = (0.0, 1.0)) | ||
A parametrized curve is a curve defined by a function `fun` that maps a | ||
(unitless) parameter `t` in the given `range` to a `Point` in space. | ||
## Examples | ||
```julia | ||
ParametrizedCurve(t -> Point(cos(t), sin(t)), (0, 2π)) | ||
``` | ||
""" | ||
struct ParametrizedCurve{M<:Manifold,C<:CRS,F<:Function,R<:Tuple} <: Primitive{M,C} | ||
fun::F | ||
range::R | ||
ParametrizedCurve{M,C}(fun::F, range::R) where {M<:Manifold,C<:CRS,F<:Function,R<:Tuple} = new{M,C,F,R}(fun, range) | ||
end | ||
|
||
function ParametrizedCurve(fun, range=(0.0, 1.0)) | ||
a, b = promote(range...) | ||
r = (a, b) | ||
p = fun(a) | ||
ParametrizedCurve{manifold(p),crs(p)}(fun, r) | ||
end | ||
|
||
paramdim(::Type{<:ParametrizedCurve}) = 1 | ||
|
||
Base.minimum(curve::ParametrizedCurve) = curve.fun(first(curve.range)) | ||
|
||
Base.maximum(curve::ParametrizedCurve) = curve.fun(last(curve.range)) | ||
|
||
Base.extrema(curve::ParametrizedCurve) = minimum(curve), maximum(curve) | ||
|
||
function (curve::ParametrizedCurve)(t) | ||
if t < 0 || t > 1 | ||
throw(DomainError(t, "c(t) is not defined for t outside [0, 1].")) | ||
end | ||
a, b = curve.range | ||
curve.fun(a + t * (b - a)) | ||
end |
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
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