Lerping multiple objects from same class?

I am building a small “tornado” using a bunch of circle objects called from the same class. I am trying to lerp them towards my mouse position, but can’t seem to. Instead, my lerp is using the mouseX and mouseY values to change the rotation radius.

I want to have it seem realistic so that the smaller (bottom) circles lerp faster towards the mouse position than the larger circles on top. It seems like a simple lerp equation, but I am stuck. Any help would be appreciated!

Code: https://github.com/Nedelstein/edeln591_dtOF_2018/tree/master/w05_h01_actNatural

Hi N,

In this case, I would use an ofNode and only translate / rotate things with it.

and write something like this:

void Circle::updatePos(glm::vec2 diffPos){
    
    float time = ofGetElapsedTimef();
    float testTime = ofSignedNoise(time)*2;
//    std::cout << "ofSignedNoise(time)*2 = " << ofToString(testTime) << std::endl;
    pos.x += diffPos.x + ofSignedNoise(time)*2;
    pos.y += diffPos.y + ofSignedNoise(time)*2;
    rotateee+=ofRandom(1,10);
}


void Circle::draw(){
    ofNode nodeExample;
    nodeExample.setPosition({pos.x, pos.y, 0});
    nodeExample.setOrientation({0, 0, rotateee});
    ofNoFill();
//    ofSetCircleResolution(3);
    ofSetColor(225);
//    ofRotateZ(rotateee);
    nodeExample.transformGL();
        ofDrawCircle(0,0, radius);
    nodeExample.resetTransform();
    
}

Hope this solves it for you, seemed to work fine for me, as a start.

Find the classes files attached.

src.zip (5.2 KB)

In your code it looks like you are not using the variable mouse:

void Circle::update(float _posX){
    glm::vec2 mouse;
    mouse.x = ofGetMouseX();
    mouse.y = ofGetMouseY();
    
    float time = ofGetElapsedTimef();
    pos.x +=ofSignedNoise(time)*2;
    pos.y +=ofSignedNoise(time)*2;
    rotateee+=ofRandom(1,10);
}

Hmm, I just changed it so it’s included, but it doesn’t seem to fix the issue.

#include "ofApp.h"
#include "Circle.hpp"


void Circle::setup(float pX, float pY, float size, float _rotationZ, float interp){
    
    pos.x = pX;
    pos.y = pY;
    radius = size;
    rotateee = _rotationZ;
    lerp = interp;

}

void Circle::update(){
    glm::vec2 mouse;
    mouse.x = ofGetMouseX();
    mouse.y = ofGetMouseY();
    
    float time = ofGetElapsedTimef();
    pos.x +=ofSignedNoise(time)*2;
    pos.y +=ofSignedNoise(time)*2;
    rotateee+=ofRandom(1,10);
    pos += (mouse - pos) * lerp;
}


void Circle::draw(){
    
    ofNoFill();
//    ofSetCircleResolution(3);
    ofSetColor(225);
    ofRotateZ(rotateee);
    ofDrawCircle(pos, radius);
    
}