Transforms
Usage
Transforms can be applied to corresponding 3D structure. Chain
can be used to compose multiple functions/transforms. Same as Flux.Chain
.
Chain
also supports indexing and slicing. See Example below.
Example
julia> t = Chain(ScalePointCloud(2.0), NormalizePointCloud())
Chain(ScalePointCloud(factor=2.0; inplace=true), NormalizePointCloud(;inplace=true))
julia> p = PointCloud(rand(1024,3))
PointCloud{Float32} Structure:
Batch size: 1
Points: 3
Normals 0
Storage type: Array{Float32,3}
julia> t(p) == t[2](t[1](p))
true
julia> m = load_trimesh("teapot.obj")
TriMesh{Float32, UInt32, Array} Structure:
Batch size: 1
Max verts: 1202
Max faces: 2256
offset: -1
Storage type: Array
julia> t = NormalizeTriMesh()
NormalizeTriMesh(;inplace=true)
julia> t(m)
TriMesh{Float32, UInt32, Array} Structure:
Batch size: 1
Max verts: 1202
Max faces: 2256
offset: -1
Storage type: Array
List of all available Transforms
Flux3D.NormalizePointCloud
Flux3D.NormalizeTriMesh
Flux3D.OffsetTriMesh
Flux3D.PointCloudToTriMesh
Flux3D.PointCloudToVoxelGrid
Flux3D.ReAlignPointCloud
Flux3D.ReAlignTriMesh
Flux3D.RotatePointCloud
Flux3D.RotateTriMesh
Flux3D.ScalePointCloud
Flux3D.ScaleTriMesh
Flux3D.TranslateTriMesh
Flux3D.TriMeshToPointCloud
Flux3D.TriMeshToVoxelGrid
Flux3D.VoxelGridToPointCloud
Flux3D.VoxelGridToTriMesh
TriMesh Transforms
Flux3D.NormalizeTriMesh
— TypeNormalizeTriMesh(; inplace::Bool=true)
Normalize TriMesh with mean at origin and unit standard deviation.
inplace
is optional keyword argument, to make transformation in-place If inplace
is set to false
, it will create deepcopy of TriMesh.
See also: normalize
, normalize!
Flux3D.ScaleTriMesh
— TypeScaleTriMesh(factor::Number; inplace::Bool=true)
Scale TriMesh with a given scaling factor factor
.
factor
should be strictly greater than 0.0
for obvious reason. inplace
is optional keyword argument, to make transformation in-place. If inplace
is set to false
, it will create deepcopy of TriMesh. Given factor
, this transform scale each vertices in TriMesh, ie. point = point * factor
Flux3D.RotateTriMesh
— TypeRotateTriMesh(rotmat::AbstractArray{<:Number,2}; inplace::Bool=true)
Rotate vertices of TriMesh with a given rotation matrix rotmat
.
rotmat
must be AbstractArray{<:Number,2}
of size (3,3)
. inplace
is optional keyword argument, to make transformation in-place If inplace
is set to false
, it will create deepcopy of TriMesh. Given rotmat
, this transform will rotate each vertices coordinates (ie. x,y,z) in TriMesh.
Flux3D.ReAlignTriMesh
— TypeReAlignTriMesh(target::TriMesh; inplace::Bool=true)
Re-Align TriMesh to axis aligned bounding box of mesh at index
in TriMesh target
.
inplace
is optional keyword argument, to make transformation in-place If inplace
is set to false
, it will create deepcopy of TriMesh.
Flux3D.TranslateTriMesh
— TypeTranslateTriMesh(vector::AbstractArray{<:Number}; inplace::Bool=true)
Translate TriMesh with given translation vector
.
inplace
is optional keyword argument, to make transformation in-place If inplace
is set to false
, it will create deepcopy of TriMesh.
See also: translate
, translate!
Flux3D.OffsetTriMesh
— TypeOffsetTriMesh(offset_verts::AbstractArray{<:Number,2}; inplace::Bool=true)
Add offset to the TriMesh by given offset vertices offset_verts
inplace
is optional keyword argument, to make transformation in-place If inplace
is set to false
, it will create deepcopy of TriMesh.
PointCloud Transforms
Flux3D.NormalizePointCloud
— TypeNormalizePointCloud(; inplace::Bool=true)
Normalize PointCloud with mean at origin and unit standard deviation.
inplace
is optional keyword argument, to make transformation in-place If inplace
is set to false
, it will create deepcopy of PointCloud.
See also: normalize
, normalize!
Flux3D.ScalePointCloud
— TypeScalePointCloud(factor::Number; inplace::Bool=true)
Scale PointCloud with a given scaling factor factor
.
factor
should be strictly greater than 0.0
for obvious reason. inplace
is optional keyword argument, to make transformation in-place. If inplace
is set to false
, it will create deepcopy of PointCloud. Given factor
, this transform scale each point in PointCloud, ie. point = point * factor
Flux3D.RotatePointCloud
— TypeRotatePointCloud(rotmat::AbstractArray{<:Number,2}; inplace::Bool=true)
Rotate PointCloud with a given rotation matrix rotmat
.
rotmat
must be AbstractArray{<:Number,2}
of size (3,3)
. inplace
is optional keyword argument, to make transformation in-place If inplace
is set to false
, it will create deepcopy of PointCloud. Given rotmat
, this transform will rotate each point coordinates (ie. x,y,z) in PointCloud.
Flux3D.ReAlignPointCloud
— TypeReAlignPointCloud(target::PointCloud; inplace::Bool=true)
ReAlignPointCloud(target::AbstractArray{<:Number, 2}; inplace::Bool=true)
Re-Align PointCloud to axis aligned bounding box of target
PointCloud.
input
PointCloud and target
PointCloud should be of same size. inplace
is optional keyword argument, to make transformation in-place If inplace
is set to false
, it will create deepcopy of PointCloud.
Conversions Transforms
Flux3D.TriMeshToVoxelGrid
— TypeTriMeshToVoxelGrid(resolution::Int=32)
Converts a TriMesh to VoxelGrid having specified resolution
.
Flux3D.PointCloudToVoxelGrid
— TypePointCloudToVoxelGrid(resolution::Int=32)
Converts a PointCloud to VoxelGrid having specified resolution
.
See also: PointCloud
, VoxelGrid
Flux3D.VoxelGridToTriMesh
— TypeVoxelGridToTriMesh(; threshold=0.5, algo=:Exact)
Converts a VoxelGrid to TriMesh.
threshold
is the threshold from which to make binary voxels, and algo
is the mode to be used to convert binary voxels. Available algo
are [:Exact, :MarchingCubes, :MarchingTetrahedra, :NaiveSurfaceNets].
Flux3D.PointCloudToTriMesh
— TypePointCloudToTriMesh(resolution::Int=32)
Converts a PointCloud to TriMesh having specified resolution
.
See also: PointCloud
, TriMesh
Flux3D.TriMeshToPointCloud
— TypeTriMeshToPointCloud(npoints::Int=1000)
Converts a TriMesh to PointCloud having npoints
.
See also: TriMesh
, PointCloud
Flux3D.VoxelGridToPointCloud
— TypeVoxelGridToPointCloud(npoints::Int=1000; threshold=0.5, algo=:Exact)
Converts a VoxelGrid to PointCloud having npoints
.
threshold
is the threshold from which to make binary voxels, and algo
is the mode to be used to convert binary voxels. Available algo
are [:Exact, :MarchingCubes, :MarchingTetrahedra, :NaiveSurfaceNets].
See also: PointCloud
, VoxelGrid