Skip to content

Commit a300ed7

Browse files
committed
upds
1 parent 26e4ae7 commit a300ed7

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

src/JTools.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ include("functions/psd.jl")
6262
export rcsMixMatrix, rcsAllocation, rcsAnalysis, rcsEnvelope, plotRcs, plotRcs!, rcsAllocationSimplex
6363
include("functions/rcsTools.jl")
6464

65-
export mesh2obj, ObjModel, readObj, writeObj
65+
export mesh2obj, ObjModel, readObj, writeObj, grid2mesh
6666
include("functions/obj.jl")
6767

6868
export includedir

src/functions/lsq.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ multivariate function f(x) = [f₁(x); f₂(x); ...; fₙ(x)].
77
88
minₓ: J = fᵀ(x) W f(x)
99
10-
NB: usually in estimation problems f(x) = y - h(x), where y are stacked noisy measurements
10+
NB: usually in estimation problems f(x) = h(x) - y, where y are stacked noisy measurements
1111
and h(x) is the nonlinear measurement model.
1212
1313
Inputs:

src/functions/obj.jl

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
function mesh2obj(m, outfile)
1+
function mesh2obj(m, outfile, flipNormal=false)
22
open(outfile, write=true) do io
33
for v in coordinates(m)
44
write(io, "v $(join(v, " "))\n")
55
end
6-
for f in faces(m)
7-
write(io, "f $(join(f, " "))\n")
6+
if flipNormal
7+
for f in faces(m)
8+
write(io, "f $(join(f[[1, 3, 2]], " "))\n")
9+
end
10+
else
11+
for f in faces(m)
12+
write(io, "f $(join(f, " "))\n")
13+
end
814
end
915
end
1016
end
1117

18+
# Pos is a matrix of 3d positions
19+
function grid2mesh(pos)
20+
Ny, Nx = size(pos)
21+
f = fill(TriangleFace([0, 0, 0]), 2(Nx - 1)*(Ny - 1))
22+
q = 1
23+
for j in 1:Nx-1, k in Ny*(j - 1)+1:Ny*j-1
24+
f[q] = TriangleFace([k, k + 1, k + Ny + 1])
25+
f[q+1] = TriangleFace([k, k + Ny + 1, k + Ny])
26+
q += 2
27+
end
28+
return GeometryBasics.Mesh(Point3f.(pos[:]), f)
29+
end
30+
1231
struct ObjModel
1332
faces::Vector{Vector{Int}}
1433
vertices::Vector{Vector{Float64}}

test/testLsq.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using JTools
22
using GLMakie
33

4-
d = collect(range(0, 6, 300))
4+
d = collect(range(0, 3, 100))
55
xTrue = [1.3; 0.4]
66
xEst0 = ones(length(xTrue))
77

0 commit comments

Comments
 (0)