Normalize turning a cylinder into a sphere

Hi everyone,

I’ve been testing the openFrameworks Essentials chapter on 3D objects deformation, but instead of doing it to a sphere I wanted to modifiy a tube/cylinder.

The issue is… my 3D primitive gets turned into a sphere? With an open top and bottom, so just a ballooned up cylinder if you will. This seems to happen when I use the glm vec3 normalize.
Would anybody know exactly what might be happening?

Thank you!


//--------------------------------------------------------------
void ofApp::setup(){

	myFbo.allocate(1000, 1000, GL_RGB);

	tempRad = 200;
	tube.set(tempRad, 1000, false);
	tube.setResolution(100, 500);  // simple 3D Primitive cyclinder with no caps

	ogVector = tube.getMesh().getVertices();

	myCam.setGlobalPosition(vec3(0, 0, 700));
	myCam.setGlobalOrientation(vec3(0, 0, 0));
	light.setPosition(0, 500, -700);

	myGui.setup();
	myGui.add(rad.set("rad", 250, 0, 500));
	myGui.add(deform.set("deform", 0.3, 0, 1.5));
	myGui.add(deformFreq.set("deformFreq", 3, 0, 10));
	myGui.add(extrude.set("extrude", 1, 0, 1));

	

}

//--------------------------------------------------------------
void ofApp::update(){


	vector<vec3> &vertices = tube.getMesh().getVertices();
	for (int i = 0; i < vertices.size(); i++) {
		vec3 v = normalize(ogVector[i]);

	//	float sinX = sin(v.x*deformFreq);
	//	float sinY = cos(v.y*deformFreq);
	//	float sinZ = sin(v.z*deformFreq) + cos(v.z*deformFreq);
	//
	//	v.x += sinY * sinZ*deform;
	//	v.y += sinX * sinZ*deform;
	//	v.z += sinX * sinY*deform;

		v *= rad;
		vertices[i] = v;
	}


}```

Hi @Potiron , normalizing a point sets its length (from the origin) to 1.0. So a point at (3, 2, 1) would normalize to roughly (0.802, 0.534, 0.267) After normalization, the vertices would all lie at a distance of 1.0 from the origin, just like a sphere of radius 1.0.