Coder Social home page Coder Social logo

shapes's Introduction

shapes

logo

This repository contains tools to generate random shapes using Bezier curves (images and meshes), controlling the number of points and the local curvature and sharpness. It is also possible to generate shapes by joining specified points using an in-house csv format, and to generate full sets of random shapes with variable parameters.

Citation

The work contained in this repository was developed for use in the following papers:

  • "A supervised neural network for drag prediction of arbitrary 2D shapes in low Reynolds number flows" pre-print, paper and source code
  • "U-net architectures for fast prediction of incompressible laminar flows" pre-print
  • "Direct shape optimization through deep reinforcement learning" pre-print, paper and source code

If you make use of this repo for your research, please consider citing them. This work was elaborated on the basis of this StackOverflow answer: https://stackoverflow.com/a/50751932/3237302, although there are now significant differences in behavior and features.

Issues

This work is provided with no guarantee whatsoever. If you find something wrong, please raise an issue. However, there is no guarantee I will have time to look into it. PRs are welcome, but the same warning applies.

CSV format

n_pts n_splg_pts
x1 y1 r1 e1
x2 y2 r2 e2
...
xn yn rn en
  • n_ctrl_pts is the actual number of points you control on the shape. Each such point is joined with the next one using a cubic Bezier curve
  • n_splg_pts is the number of sampling points per unit of distance between two control points
  • xi yi are the coordinates of the control points
  • ri is the local radius around control point i. It measures how far the local control points are from the point you provided
  • ei is a local measure of sharpness

Give a look at the examples below for a better understanding of the effects of radius and sharpness parameters. Maximum smoothness is usually obtained for r = 0.5 and e = 0.0 on all points.

Shape examples

csv shape
4 30
1.0 1.0 0.707 0.0
-1.0 1.0 0.707 0.0
-1.0 -1.0 0.707 0.0
1.0 -1.0 0.707 0.0

4 30
1.0 1.0 0.707 0.0
-1.0 1.0 1.0 0.0
-1.0 -1.0 0.707 0.0
1.0 -1.0 0.0 0.0

4 30
1.0 1.0 0.707 0.0
-1.0 1.0 0.707 0.0
-1.0 -1.0 0.707 0.0
1.0 -1.0 0.707 1.0

4 30
-1.0 0.0 0.5 0.0
0.0 0.1 0.7 0.0
1.0 0.0 0.5 0.0
-0.5 0.4 0.7 0.0

10 30
-0.22344386973718572 -0.11579347020968898 0.5 0.0
-1.086703349116176 0.056471511909076864 0.5 0.0
0.33918645130375696 -0.6285322803621614 0.5 0.0
0.09673486000147186 0.020665843303720587 0.5 0.0
0.7184144807034846 0.07933772977561572 0.5 0.0
0.658776975915066 -0.5602669680651731 0.5 0.0
-0.5629917814532847 0.37355108023884465 0.5 0.0
-0.5526944074292542 0.6349363861837116 0.5 0.0
0.44487187686581814 -0.19528679943835178 0.5 0.0
0.16784876294630274 0.3349169666644063 0.5 0.0

Generating datasets

Generate a dataset of random shapes using python3 dataset.py (parameters of the dataset can be modified inside the python file). It will generate images and meshes in separated folders.

shapes's People

Contributors

jviquerat 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

Watchers

 avatar  avatar  avatar

shapes's Issues

Explain parameters

Hey,

cool project! But could you maybe document what the parameters do?

For example the parameters in generate_dataset?

magnify = 1.0
xmin =-2.0
xmax = 2.0
ymin =-2.0
ymax = 2.0
n_tri_max = 5000

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.