Jump to content

[SOLVED] Fibonacci sprial movement for objects


photo

Recommended Posts

Hello everyone ,

Nowadays I am working on a project that consist of several important movements for objects.But unfortunately I couldn't realize Fibonacci spiral movement.Circular and linear positioınal movements are available on my object.But could you please help me on Fibonacci circular motion.Is there any prepared function for this or how to integrate it in unigispacer.pngne for c++?

Basically object should move like below image:

 

Thank you by now, 

Fibonacci_spiral.png

Link to comment

Hello,

Spiral movement can be achieved with this code:

float angle = 0;
void update()
{
    float ifps = Game::get()->getIfps();
    angle += 90.0f * ifps;
    node->setRotation(node->getRotation() * quat(0, 0, angle * ifps));
    node->setPosition(node->getPosition() + node->getDirection() * ifps);
}

If you want exact Fibonacci spiral, you may want to check this implementation:

https://www.quora.com/How-Fibonacci-spiral-can-be-drawn-with-a-C-algorithm

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Thank you for information, it moves very well.I think your function will be enough instead of Fibonacci movement.I have one problem, it rotates according to given object orientation and size but I want to rotate it around bigger circle.

Sorry for bad drawing :) .

For example it moves like this;

 

Spiralmovement.png

Link to comment

Hi,
Simple decrease the "angular_speed" variable and/or increase the "linear_speed" to rotate it around bigger circle.

// public
float angular_speed = 45.0f;
float linear_speed = 10.0f;

// private
float angle = 0;

void update()
{
    float ifps = Game::get()->getIfps();
    angle += angular_speed * ifps;
    node->setRotation(node->getRotation() * quat(0, 0, angle * ifps));
    node->setPosition(node->getPosition() + node->getDirection() * linear_speed * ifps);
}


Best regards,
Alexander

Link to comment
  • morbid changed the title to [SOLVED] Fibonacci sprial movement for objects
×
×
  • Create New...