Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evaluate FRep at vector of inputs #52

Open
vpuri3 opened this issue Oct 16, 2021 · 3 comments
Open

evaluate FRep at vector of inputs #52

vpuri3 opened this issue Oct 16, 2021 · 3 comments

Comments

@vpuri3
Copy link
Contributor

vpuri3 commented Oct 16, 2021

Hello, I'd like to evaluate FReps at a vector of inputs as follows:

julia> using Descartes

julia> c = Circle(1.0)
Circle{Float64}(1.0)

julia> x = rand(2,10);

julia> FRep(c,x[1])
-0.8388503806040237

julia> f = FRep(c,x)
1.382979664762074

I would like the final output f to be a vector of size [1,10] with f[i] = FRep(c,x[i]). Could you help me get started with implementing this?

@vpuri3
Copy link
Contributor Author

vpuri3 commented Oct 16, 2021

FYI - I'd like to use Descartes to model geometry for my differentiable meshing algorithms - https://github.com/vpuri3/DiffMesh.jl

@sjkelly
Copy link
Member

sjkelly commented Oct 18, 2021

It is strange that

julia> FRep(c,x[1])
-0.8388503806040237

does not error in your example.

Something like the following would give you a generator for the points, which can be nice for iterative methods.

julia> using Descartes

julia> c = Circle(1.0)
Circle{Float64}(1.0)

julia> x = rand(2,10);

julia> f(x) = FRep(c, x)
f (generic function with 1 method)

julia> collect(f(x[:,i]) for i in 1:size(x)[2])
10-element Vector{Float64}:
 -0.2540315834260186
 -0.06483389183029131
 -0.8770595028565922
 -0.4213730472330932
 -0.4748196284624575
 -0.40939828690307556
 -0.17437016828320873
 -0.25766200363764136
 -0.11564304875354436
 -0.19694540348031064

I'm sure there is a way to do this with broadcasting syntax as well.

@vpuri3
Copy link
Contributor Author

vpuri3 commented Oct 19, 2021

addressed here: #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants