JuliaGeometry / JuliaGeometry/GeometryBasics.jl

Type changes when using faces to index points

Open
#262 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
215
Forks
64
Avg merge
3d 18h
Merged PRs (30d)
2

Description

When defining a face vector F and a point vector V one could access the points for face 1 like this:

V[F[1]]

I've noticed that the type returned by the above is first of all not the same type as V (which would be desirable for my applications, but perhaps you have reasons to change the type) but also that the type depends on the face integer type.

For instance here using Int32:

T = Int32
F = TriangleFace{T}[ [1,2,3] ]
V = Point{3,Float64}[ [0.0,0.0,0.0], [1.0,0.0,0.0], [1.0,1.0,0.0]]

vf = V[F[1]]
println(typeof(vf))

The type of vf is: StaticArraysCore.SVector{3, Point{3, Float64}}
Whereas when using Int64,

T = Int64
F = TriangleFace{T}[ [1,2,3] ]
V = Point{3,Float64}[ [0.0,0.0,0.0], [1.0,0.0,0.0], [1.0,1.0,0.0]]

vf = V[F[1]]
println(typeof(vf))

The type of vf is: StaticArraysCore.SizedVector{3, Point{3, Float64}, Vector{Point{3, Float64}}}.

The returned types should probably be the same right?

Side note, V[F[1][1:end]] returns a Vector of Points so is different from V[F[1]] again. Would it not be best to always just return a vector of Points?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported behavior with the Int32 and Int64 examples using V[F[1]], then compare it with V[F[1][1:end]]. Trace the face-indexing and point-vector indexing entry points to identify where the return type diverges. Done means the supported indexing forms have a consistent, documented return type and regression coverage for both integer types.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.