Skip to content

eonist/Cube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mit platform platform Lang Carthage compatible codebeat badge

Cube

img

What is it

Convert perspective square to perspective cube

How does it work

  • Finds perspective vanishing points
  • Uses law of ratios to find correct volume
  • Returns 2d-Points of the cube bounds

How do I get it

  • Carthage github "eonist/Cube"
  • Manual Open Cube.xcodeproj
  • CocoaPod (Coming soon)

Example:

let corners:[CGPoint] = [.init(x:100,y:130),.init(x:220,y:150),.init(x:200,y:220),.init(x:130,y:240)]
let quad:Quad = (corners[0],corners[1],corners[3],corners[2])
let cube:Cube = CubeUtil.cube(quad:quad)
let cubeGraphic:CubeGraphic = .init()
layer.addSublayer(cubeGraphic)
cubeGraphic.drawCube(cube: cube)

References:

Todo:

  • Add support for 1 point perspective Quadrilaterals ✅
  • Add support for horizontal 1p quads (co-linear, epsilon etc) ✅
  • Add support for square w/o perspective ✅
  • Optimize the math for performance 👈
  • Account for object relation to POV 👈

About

Convert perspective square to perspective cube

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published