Giter Site home page Giter Site logo

ln's People

Contributors

bpowers avatar fogleman avatar ziotom78 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ln's Issues

Union is missing

Union is not implemented if I'm correct, but it is advertised in the ReadMe. Is there a simple way to activate it?

Requires cairo

fyi

"github.com/ungerik/go-cairo"
- requires a project which requires the cairo library, meaning there are external requirements. Would you take a PR for the docs?

Orthographic Errors

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.

screen shot 2018-01-07 at 4 32 53 am

Render Occluded Lines as Dashes

In the example images, there is one example that shows several cubes whose occluded lines are drawn as dashes. How do you achieve this effect?
screen shot 2018-01-01 at 3 47 39 pm

Gravitional waves example

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?

Error: Failed to download resource "libpng"

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

Any idea why some hidden lines are not hidden?

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):
image

My ported C++ code (not exactly the same due to the random heights of the towers):
image

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:
image

The ported example1.go with multiple cubes looks correct under C++:
image

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?

Cannot find cairo-pdf.h (fixed)

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"

Malloc deadlock in rendering large OBJ

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

Support go modules

This is a fantastic library, thank you!

One suggestion: it would become more versatile if the code was updated to support Go modules.

Go noobz not supported

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?

Optimization for intersections on Triangle

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.