Important: Please read the Qt Code of Conduct  https://forum.qt.io/topic/113070/qtcodeofconduct
Path length instead of degrees.

Hi, i am using QGraphicsScene, and there i wanna rotate one object, nearly another one. The static object is a circle, the moving object should move around the path.
This is good, i can already simply rotate it. The problem is, i don't want to rotate it, i want to move it around that circle, but by the path length, so if the circle has 4000 length of any kind of units, so if i move it by 1000 units, it should do the angle of 90.
(4000 / 1000 = 4  360 / 4 = 90)I dont want the angles, i want the path size, how could i achieve it? I have no idea how to do it, i just started with QGraphicsScene.

Hi
but what is "the path" ?

Road, way, lengh, distance value.

@Loc888
Ok, im not really sure what you mean.
Do you have an image of it ?

@mrjj
Image? All i want, is instead of using 360 degrees, use a distance value.
So if the circle has 120 cm of length, if i move another item on this circle by 60cm, it should do a 180 degree move.

Then why don't you just calculate it? This is very simple math, you already gave an example yourself.

@aha_1980 If i am posting it, i have the reason. In short reply, because of the accuracy, i will move that object by very small values. There are few more things, but doing it in this way make it useless.

This post is deleted!

@Loc888 Angle and circumference have a fixed ratio. Why should one be more or less precise than the other one?

@aha_1980 If you don't know how to do it, that's it, i will not talk about anything else, i know what i wanna achieve.

Right, I don't know how to do it, because you didn't supply a picture of your task.
But guess what: I don't care. And I won't talk anymore, too.
Regards

@aha_1980 How can i take a picture of units of length? If you can explain it.

a shot in the dark here, because I'm not entierly sure what you want to do, but this (it's untested)
should give you a point(x,y) depending on the radius and the length of the partial circumference.its untested, and I think you'll need to adjust it to the correct point of origin
QPoint lengthToPoint(const int radius, const int semiCyrcleLength) { //arc angle double angle = (semiCyrcleLength *360)/(2* 3.1415 * radius); //angle to x & y QPoint p(cos(angle),sin(angle)); return p; }

@Loc888 said in Path length instead of degrees.:
if the circle has 4000 length of any kind of units, so if i move it by 1000 units, it should do the angle of 90.
(4000 / 1000 = 4  360 / 4 = 90)...
So if the circle has 120 cm of length, if i move another item on this circle by 60cm, it should do a 180 degree move.
double findDegrees(double fullCircleLength, double pathLength) { double ratio = fullCircleLength / pathLength; double angle = 360 / ratio; return angle; } int main() { qDebug() << findDegrees(4000, 1000); // Output: 90 qDebug() << findDegrees(120, 60); // Output: 180 return 0; }
Is this what you want?
@mrjj
Image? All i want, is instead of using 360 degrees, use a distance value.Look, your words were not clear.
@mrjj asked you for an image so that he can understand what you want, so that he can help you. If you don't want to give him the image, then he cannot help you.
@aha_1980 If you don't know how to do it, that's it, i will not talk about anything else, i know what i wanna achieve.
@aha_1980 was also trying to help you. There is no need to be rude.

@JKSH I am not trying to be rude, i just wanted to say, i am not interested in doing this, by another way.
I am not sure if i am explaining it bad, but if you can't understand it, or maybe you are not sure, then i will make a simple image of it, maybe it will help.

@Loc888 said in Path length instead of degrees.:
@JKSH I am not trying to be rude, i just wanted to say, i am not interested in doing this, by another way.
OK.
I am not sure if i am explaining it bad, but if you can't understand it, or maybe you are not sure, then i will make a simple image of it, maybe it will help.
Yes, please do.
Both @JHilk and myself have tried to understand your question, and we both gave you some code. If the code is not what you want, that means we can't understand what you want. A simple image will be very helpful.

This post is deleted!

Image1: https://tinypic.pl/v6f0sy6qi612
Image2: https://tinypic.pl/hwvlldlzqaah
Image3: https://tinypic.pl/zs4be25yzsjr < This one is the most important.

@Loc888 said in Path length instead of degrees.:
Image1: https://tinypic.pl/v6f0sy6qi612
Image2: https://tinypic.pl/hwvlldlzqaah
Image3: https://tinypic.pl/zs4be25yzsjr < This one is the most important.Great, thank you.
You can use the
findDegrees()
function that I wrote before, right?double findDegrees(double fullCircleLength, double pathLength) { double ratio = fullCircleLength / pathLength; double angle = 360 / ratio; return angle; }
The function calls below will give you the same results:
this>ball_P>setRotation( findDegrees(50000, 25000) );
this>ball_P>setRotation(180);

@JKSH Ok, but it will work with if i wanna move it by 50,03674 or something like this? I saw it's double, but i am not sure.

@Loc888 said in Path length instead of degrees.:
@JKSH Ok, but it will work with if i wanna move it by 50,03674 or something like this?
Try it and see.
I saw it's double, but i am not sure.
What's wrong with
double
?

@JKSH Nothing, i am not sure if it will work with that decimal numbers.

@Loc888 said in Path length instead of degrees.:
i am not sure if it will work with that decimal numbers.
Yes it will.
double
is designed for decimal numbers.Read this carefully: https://www.learncpp.com/cpptutorial/25floatingpointnumbers/
EDIT: If you are worried about rounding errors in
double
s, remember this: Your user won't be able to see any difference if the "dynamic object" is off by 0.001 degrees!

@JKSH If you are worried about rounding errors in doubles, remember this: Your user won't be able to see any difference if the "dynamic object" is off by 0.001 degrees!
Yes, it was that, that's why i said "I am not sure about this double", i know double it's ok, but it was that.
I tested it, and for now seems to work very good.