Path length instead of degrees.
-
This post is deleted!
-
@Loc888 Angle and circumference have a fixed ratio. Why should one be more or less precise than the other one?
-
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
-
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 @J-Hilk 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);
-
@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
? -
@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/cpp-tutorial/25-floating-point-numbers/
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.
16/24