Coder Social home page Coder Social logo

inkscape-raytracing's Introduction

Inkscape-raytracing

An extension for Inkscape that makes it easier to draw optical diagrams.

Allows to annotate Inkscape primitives with optical properties and draws beam paths by taking into account reflection and refraction.


Examples

How to install

Copy the extension directory in inkscape user extensions directory.

Typically for Linux users:

cd ~/.config/inkscape/extensions
git clone https://github.com/damienBloch/inkscape-raytracing

Requires python3.6 or above with numpy and Inkscape1.0 or above.

How to use

1. For each optical element, write its optical property in the element description:

The property that needs to be written in the element description can be any of the following:

  • optics:beam: source of the ray. Need at least one element with this property to see an effect. Typically the element should be a straight line.
  • optics:mirror: reflects an incoming beam. Element can be a closed or open shape.
  • optics:beam_dump: absorbs all incoming beams. Element can be a closed or open shape.
  • optics:beam_splitter: for each incoming beam, produces one transmitted beam and one reflected beam. Element can be a closed or open shape, but closed shape will cause the number of beams to increase exponentially.
  • optics:glass:<optical_index>: transmits and bends a beam depending on its optical index. Element must be a closed shape.

An element can have at most one optical property and will be ignored if it has two or more.

It is possible to add complementary text in the description. If it doesn't have the syntax optics:<something>, the extra text will simply be ignored.

2. Select the elements to render and run the extension:

3. This will trace all the beams originated from an optics:beam element:

Note that the borders of the document blocks the beams and all objects outside the document page will be ignored.

Known limitations

  • Cannot write the properties in a group description. They must be written in the primitives description.
  • Avoid overlapping or touching elements. It won't cause Inkscape to crash, but might give unexpected results.
  • The same goes for self-intersecting paths.
  • Because of a potential issue with Inkscape python extensions, transformations like rotations or reflections are not always correctly applied to groups of elements, rectangles and ellipses. This might cause the ray tracing to output blatantly wrong results or to seemingly ignore some objects. A possible workaround is to ungroup all objects and convert them to path before applying any rotation or reflection. WIP.

inkscape-raytracing's People

Contributors

damienbloch avatar zander avatar

Watchers

 avatar

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.