https://github.com/edap/ofxphyllotaxis
Phyllotaxis algorithm implementation for openFrameworks
https://github.com/edap/ofxphyllotaxis
addon algorithmic-botany botanics openframeworks phyllotaxis
Last synced: 4 months ago
JSON representation
Phyllotaxis algorithm implementation for openFrameworks
- Host: GitHub
- URL: https://github.com/edap/ofxphyllotaxis
- Owner: edap
- License: mit
- Created: 2017-05-06T18:55:11.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-03T08:08:26.000Z (about 7 years ago)
- Last Synced: 2025-07-03T19:49:08.807Z (7 months ago)
- Topics: addon, algorithmic-botany, botanics, openframeworks, phyllotaxis
- Language: Makefile
- Homepage:
- Size: 649 KB
- Stars: 28
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ofxPhyllotaxis
[](https://travis-ci.org/edap/ofxPhyllotaxis)
[](https://ci.appveyor.com/project/edap/ofxphyllotaxis)
This addons simply consists of three static methods that implements a model that describes the arrangement of leaves on a plant stem, called phyllotaxis.
## Usage
It can be used to position the elements of a collection composed by 2D or 3D forms. For example, assuming you have a bunch of `ofBoxPrimitive` in a vector, it can be used in a loop like this:
```cpp
// initialize a collection
children vector;
int nCubes = 400;
for (int i = 0; i < nCubes; i++) {
children.push_back(ofBoxPrimitive(5,5,5));
}
// iterate and position items
float rad = ofDegToRad(137.5);
float spread = 0.3;
for (int i = 0; i < nCubes; i++) {
glm::vec3 pos;
pos = ofxPhyllotaxis::simple(i, rad, spread);
children[i].setPosition(pos);
}
```
In the example application, it is used in a 3D scene. It provides 3 methods slightly differents from each other.
### Simple

```cpp
glm::vec3 simple(const int i, const float angleInRadians, const float spread)
```
`i` is the current index in the iteration
`angleInRadian` is the angle that is used in the phyllotaxis. It needs to be expressed in radians
`spread` defines how much each element should be distant from the previous one
## Conical

```cpp
glm::vec3 conical(const int i, const float angleInRadians,const float spread, const float extrude)
```
The parameters are the same as before, except
`extrude` defines how much the elements should be pushed on the `y` axis
## Apple
I did not find any better name, feel free to give me suggestions.
The following picture is taken from "inside the apple".

```cpp
glm::vec3 apple(const int i, const float angleInRadians, const float spread, const int total)
```
The parameter `total` indicates the total number of the element in the collection.