Jump to content

Prot

Member Since 05 Jul 2013
Offline Last Active Dec 14 2016 04:07 AM

Posts I've Made

In Topic: Rotating object around its own center

14 December 2016 - 03:16 AM

Your vertices all have a value of negative -0.5 in the z axis. That means that the center of the quad is not the center of the model. The rotate function as you are using it rotates around the center of the model. Set the values of the -z axis to 0 to make the quad and model center the same and it should be rotating around the center of the quad

 

This did the trick thank you!


In Topic: Point around point rotation

15 August 2016 - 08:59 AM

It would have been nice if you had told us what numbers you were getting as part of your initial report.

 

Just as an additional information. I am trying to construct a function which draws a Koch Curve according to the number of desired iterations. That would need an angle of 60° or (Pi / 3).

 

But when I was debugging the rotate_point-function I was using (0,0) as origin and (1,0) as the "rotating" point and an angle of 90° (or Pi / 2), because it's easier to debug.


In Topic: Point around point rotation

15 August 2016 - 07:18 AM

"What's cos(pi/3) etc and we'd have to just know theie exact values. There's a bunch of them here. Can be useful if you need to optimize some specific cases (such as rotating 90 degrees can be common).

 

 

Thank you guys for all the advice. While it propably is a good idea to know all those values by heart I tried the following:

const GLfloat pi = glm::pi<float>();

GLfloat x = point_a.x + (point_b.x - point_a.x) * glm::cos(pi / 2) - (point_b.y - point_a.y) * glm::sin(pi / 2);
GLfloat y = point_a.y + (point_b.x - point_a.x) * glm::sin(pi / 2) + (point_b.y - point_a.y) * glm::cos(pi / 2);

The results were exactly the same (as expected :D ). An I know I shouldn't recalculate whose values every time, I will not (promise).

 

So bottom line -4.37113883e-008 is ok I have to live with it :D


In Topic: Point around point rotation

15 August 2016 - 03:29 AM

I don't see a problem in your code. Perhaps you can provide a few more lines of code to turn this into a complete program that we can run ourselves to see the problem. If you could do so without depending on external libraries, it would be much better.

 

 

Well my problem is the following:

 

If I try rotating the point (1,0) around the origin (0,0) I get unprecise output values. I call:

glm::vec2 point = rotate_point(glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 0.0f), 90);

It returns:

 

x = -4.37113883e-008

y = 1.00000000

 

I mean this is ok, but I wish x would be exactly 0 here. I traced back this inaccuracy down to the glm::cos function where I calculate:

GLfloat angle_radians = glm::radians(angle);

GLfloat costest = glm::cos(angle_radians);

Here costest = -4.37113883e-008 but should be exactly 0. I mean if I do this calculation using degree in the windows calculator it returns exactly 0. What is the right way to achieve this accuracy in my code.

 

Let's be honest this small error doesn't break my code neither does it distort the drawing result, still this can't be the best solution.


In Topic: Triangle rendered white only.

15 February 2016 - 03:41 AM

if you change it to the above code it should have the right size even if you change your vector.

 

As for the problem of the colours does hard coding a colour into your shader change it to that colour? So something like

out_color = vec4(1.0, 0.0, 0.0, 1.0);

that should change the triangle to red. I know you don't want just a red one but this will eliminate the shader as the problem

 

 

Actually it does not change anything.

 

I have to take the time to try all the other suggestions.