fogleman / ln Goto Github PK
View Code? Open in Web Editor NEW3D line art engine.
Home Page: https://godoc.org/github.com/fogleman/ln/ln
License: MIT License
3D line art engine.
Home Page: https://godoc.org/github.com/fogleman/ln/ln
License: MIT License
in earth.go:
func LoadPaths() ln.Paths {
var result ln.Paths
file, err := shp.Open("examples/ne_10m_coastline/ne_10m_coastline.shp")
I'm extremely new to Go so apologies if this is a stupid issue but I can't seem to get this to run
Union is not implemented if I'm correct, but it is advertised in the ReadMe. Is there a simple way to activate it?
http://store.makeblock.com/xy-plotter-robot-kit/ 404s in the README
What paper to you recommend to read to understand the science behind this project?
Thanks in advance!
Not sure what else is out there that will suit your needs though it would be handy if this package was pure Go
fyi
Line 8 in 73feb4b
Hi, I'm trying to do some tests using an orthographic matrix, but I seem to be getting some errors in the ray intersection. I don't know if I've set something up wrong.
eye := ln.Vector{-3, 4, 3} // camera position
center := ln.Vector{0, 0, 0} // camera looks at
up := ln.Vector{0, 1, 0} // up direction
znear := 0.1 // near z plane
zfar := 10.0 // far z plane
step := 0.01 // how finely to chop the paths for visibility testing
matrix := ln.LookAt(eye, center, up).Orthographic(-1, 1, -1, 1, znear, zfar)
paths := scene.RenderWithMatrix(matrix, eye, width, height, step)
As you can see, edges are clipped before they go behind objects.
Hello,
I really like the ln library and I've been using it with a drawbot I've built. Thank you!
I am trying to generate the gravitational waves example from the image in the Readme. I've gone through all of the examples and I can't seem to figure out how to generate that. I've successfully generated run all of the other examples. Can you elaborate on how that specifically is done?
curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "libpng"
Download failed: https://dl.bintray.com/homebrew/mirror/libpng-1.6.18.tar.xz
When running the examples everything looks great!
I ported the code to C++ and run the samples again.
Usually everything looks fine.
However, under some viewing angles I get different results with the ported C++ compared to the original GO code....
Cannot find differences after spending hours of comparisons - but it looks like I'm missing some GO-specifics...
Example: the GO Skyscraper example (simplified to only show a few towers):
My ported C++ code (not exactly the same due to the random heights of the towers):
Do you, does anyone have an idea, why some of the hidden lines are not hidden?
Depending on the viewing angle it gets more visible - but only for the closer object:
The ported example1.go
with multiple cubes looks correct under C++:
Do you, does anyone see a typical root cause for such effects?
Rounding? Different slicing details between GO and C++? Trapped by some call-by-value and call-by-reference between GO and C++?
Is it a range of the viewer only, SIN or COS flipping (like with Euler-Coordinates/Gimbal-Lock)?
Any idea?
In case someone else has this problem: after running
go get github.com/ungerik/go-cairo
I got an error about cairo-pdf.h being not found; this was from the include cairo-pdf.h (among other headers), where the "include" no longer worked properly because of where cairo's files were held (recent Mac OX has an Xcode path instead of the /usr/include which causes problems).
Short story solution: installed some Xcode "command line developer tools" using
xcode-select --install
from the terminal. No more error. Not sure if this is the best way, but see here.
edit: called "command line developer tools"
Running
package main
import "github.com/fogleman/ln/ln"
func main() {
tree, err := ln.LoadOBJ("tree.obj")
if err != nil {
panic(err)
}
scene := ln.Scene{}
scene.Add(tree)
// define camera parameters
eye := ln.Vector{4, 3, 2} // camera position
center := ln.Vector{0, 0, 0} // camera looks at
up := ln.Vector{0, 0, 1} // up direction
// define rendering parameters
width := 1024.0 // rendered width
height := 1024.0 // rendered height
fovy := 50.0 // vertical field of view, degrees
znear := 0.1 // near z plane
zfar := 10.0 // far z plane
step := 0.01 // how finely to chop the paths for visibility testing
// compute 2D paths that depict the 3D scene
paths := scene.Render(eye, center, up, width, height, fovy, znear, zfar, step)
paths.WriteToPNG("out.png", width, height)
// save the paths as an svg
paths.WriteToSVG("out.svg", width, height)
}
with tree.obj
being a large OBJ file (15MB) gives
panic: fatal error: malloc deadlock
runtime stack:
runtime.throw(0x151fc0, 0xf)
/home/pi/golang/go/src/runtime/panic.go:527 +0x78
runtime.mallocgc(0x21, 0x0, 0x3, 0x1864a8)
/home/pi/golang/go/src/runtime/malloc.go:513 +0x13c
runtime.rawstring(0x21, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/pi/golang/go/src/runtime/string.go:264 +0x64
runtime.rawstringtmp(0x0, 0x21, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/pi/golang/go/src/runtime/string.go:107 +0xb4
runtime.concatstrings(0x0, 0x45f57a38, 0x2, 0x2, 0x0, 0x0)
/home/pi/golang/go/src/runtime/string.go:48 +0x1e4
runtime.concatstring2(0x0, 0x1523c0, 0xf, 0x1556e8, 0x12, 0x0, 0x0)
/home/pi/golang/go/src/runtime/string.go:58 +0x58
runtime.(*errorString).Error(0x569a4010, 0x0, 0x0)
<autogenerated>:2 +0xd8
runtime.printany(0x12b5b0, 0x569a4010)
/home/pi/golang/go/src/runtime/error.go:75 +0x140
runtime.gopanic(0x12b5b0, 0x569a4010)
/home/pi/golang/go/src/runtime/panic.go:352 +0x5c
runtime.panicindex()
/home/pi/golang/go/src/runtime/panic.go:12 +0x48
runtime.mHeap_Grow(0x1ed0e0, 0x8, 0x0)
/home/pi/golang/go/src/runtime/mheap.go:647 +0x25c
runtime.mHeap_AllocSpanLocked(0x1ed0e0, 0x1, 0x0)
/home/pi/golang/go/src/runtime/mheap.go:532 +0x6c8
runtime.mHeap_Alloc_m(0x1ed0e0, 0x1, 0xd, 0x0, 0x5d26c)
/home/pi/golang/go/src/runtime/mheap.go:425 +0x23c
runtime.mHeap_Alloc.func1()
/home/pi/golang/go/src/runtime/mheap.go:484 +0x40
runtime.systemstack(0x45f57be4)
/home/pi/golang/go/src/runtime/asm_arm.s:256 +0xa8
runtime.mHeap_Alloc(0x1ed0e0, 0x1, 0xd, 0x100, 0x1)
/home/pi/golang/go/src/runtime/mheap.go:485 +0x58
runtime.mCentral_Grow(0x1f20d0, 0x0)
/home/pi/golang/go/src/runtime/mcentral.go:190 +0xb0
runtime.mCentral_CacheSpan(0x1f20d0, 0x43ada1ac)
/home/pi/golang/go/src/runtime/mcentral.go:86 +0x5e0
runtime.mCache_Refill(0x4685925c, 0xd, 0x43ada1ac)
/home/pi/golang/go/src/runtime/mcache.go:118 +0xd4
runtime.mallocgc.func2()
/home/pi/golang/go/src/runtime/malloc.go:611 +0x28
runtime.systemstack(0x569b7400)
/home/pi/golang/go/src/runtime/asm_arm.s:242 +0x80
runtime.mstart()
/home/pi/golang/go/src/runtime/proc1.go:674
goroutine 1 [running]:
runtime.systemstack_switch()
/home/pi/golang/go/src/runtime/asm_arm.s:187 +0x4 fp=0x5ec8b90c sp=0x5ec8b908
runtime.mallocgc(0xc0, 0x0, 0x3, 0x8)
/home/pi/golang/go/src/runtime/malloc.go:612 +0x840 fp=0x5ec8b978 sp=0x5ec8b90c
runtime.rawmem(0xc0, 0x30)
/home/pi/golang/go/src/runtime/malloc.go:788 +0x30 fp=0x5ec8b98c sp=0x5ec8b978
runtime.growslice(0x136148, 0x768e44e0, 0x4, 0x4, 0x5, 0x0, 0x0, 0x0)
/home/pi/golang/go/src/runtime/slice.go:92 +0x230 fp=0x5ec8b9c4 sp=0x5ec8b98c
github.com/fogleman/ln/ln.Path.Chop(0x59a9e840, 0x2, 0x2, 0x47ae147b, 0x3f847ae1, 0x0, 0x0, 0x0)
/home/pi/golang/projects/src/github.com/fogleman/ln/ln/path.go:41 +0x434 fp=0x5ec8bb28 sp=0x5ec8b9c4
github.com/fogleman/ln/ln.Paths.Chop(0x61e14000, 0xe29c8, 0xe2aaa, 0x47ae147b, 0x3f847ae1, 0x0, 0x0, 0x0)
/home/pi/golang/projects/src/github.com/fogleman/ln/ln/path.go:131 +0xc0 fp=0x5ec8bb88 sp=0x5ec8bb28
github.com/fogleman/ln/ln.(*Scene).Render(0x576ac340, 0x0, 0x40100000, 0x0, 0x40080000, 0x0, 0x40000000, 0x0, 0x0, 0x0, ...)
/home/pi/golang/projects/src/github.com/fogleman/ln/ln/scene.go:47 +0x398 fp=0x5ec8be7c sp=0x5ec8bb88
main.main()
/home/pi/golang/projects/src/github.com/tdewolff/tree/main.go:28 +0x2e0 fp=0x5ec8bf9c sp=0x5ec8be7c
runtime.main()
/home/pi/golang/go/src/runtime/proc.go:111 +0x2b4 fp=0x5ec8bfc4 sp=0x5ec8bf9c
runtime.goexit()
/home/pi/golang/go/src/runtime/asm_arm.s:1036 +0x4 fp=0x5ec8bfc4 sp=0x5ec8bfc4
goroutine 17 [syscall, 2 minutes, locked to thread]:
runtime.goexit()
/home/pi/golang/go/src/runtime/asm_arm.s:1036 +0x4
on a Raspberry Pi 2B, Debian. The OBJ file I used is here: http://pi.tacodewolff.nl:8080/tree.obj
I noticed that "suzanne.obj" is provided, but not "mountain.csv"
This is a fantastic library, thank you!
One suggestion: it would become more versatile if the code was updated to support Go modules.
D:\src\go>md bin
D:\src\go>md src
D:\src\go>md pkg
...
D:\src\go>set GOPATH=D:\src\go
D:\src\go>go get github.com/fogleman/ln
package github.com/fogleman/ln: no buildable Go source files in D:\src\go\src\github.com\fogleman\ln
If applicable, would you consider adding missing steps to readme.md to support this use case: I don't want to learn Go from scratch, I just want to use your app to create svg files?
Hi, very nice library so simple and powerful in same time.
I'm trying to do elevation for floor plan, orthographic camera on irregular polygon shape, really stack on intersect method for irregular polygon shape.
What is the simplest way to hide not visible lines? triangulate and create mesh and use mesh shape?
babylon.js have polyMeshBuilder https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/polyMeshBuilder#polygon-mesh-builder
Thanks
There is an optimization you can make for you Triangle type, though it sort of prevents using Triangle literals.
type Triangle struct {
V1, V2, V3 Vector
Box Box
intersection func(Ray) HIt
}
func NewTriangle(....) Triangle {
t.intersection = t.generateInsersectionFunction()
return t
}
func (t *Triangle) generateInsersectionFunction() {
// Precalculate things like determinants etc here, return the function with these pre-computed
}
func (t *Triangle) Intersection(r Ray) {
if t.intersection == nil { t.generateIntersectionFunction()}
return t.intersection(r)
}
a useful optimization if you are doing a lots of intersections.
Now: go get github.com/fogleman/ln
Should be: go get github.com/fogleman/ln/ln
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.