meixue
August 12, 2021, 3:07am
1
I want to draw a circle by a function, like sqrt(1-xx), how should I write the code?
This is my code and the plot I have drawn:
but when I add sqrt to the function:sqrt(1-x x), then It willbe a warning,like that
And I also met this question in other code, what should I do to fix it?
ferhue
August 12, 2021, 10:45pm
3
You could use a parametric function x(t), y(t) and build a TGraph instead:
[quote]Timur, try to draw a circle with “const Int_t nPoints = 20”.
With Bezier interpolation you will get “correct” circle with less number of subdivisions.[/quote]
Gagagaga!!! Podlovil, aga.
Why not nPoints == 3? Or 2? But again, Olivier is right about TGraph and its option “C”.
But… how do you build these nice cubic splines? You have cool computet, which can draw curves??? Or you still aproximate them this some subdivisions??? So, stop flame!!!
voilà, nPoints == 20. TGraph:
[image]
(Or use a TGraphPolar ROOT: TGraphPolar Class Reference )
couet
August 18, 2021, 9:13am
4
Can you post the code you are running which reproduces your problem ? Screen Shots are not convenient…
Hi,
as already suggested TEllipse is the best solution.
Concerning your code the problem is that you are using the range (-2,2) and when x is larger than 1 or smaller than -1 the sqrt is not defined.
system
Closed
September 8, 2021, 9:50am
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.