acircle.getCenter() to (x,y) coordinates in Python

MRAB python at mrabarnett.plus.com
Sun Dec 24 13:51:02 EST 2017


On 2017-12-24 02:31, G Yu wrote:
>> But your code has:
>> 
>>      moving_circle.move(P_to_R/P_to_E, E_to_R/P_to_E)
>> 
>> so won't that move the circle and change what:
>> 
>>      moving_circle.getCenter()
>> 
>> returns?
> 
> Yes, moving the circle changes the value of moving_circle.getCenter(). The problem is interpreting the output. The command gives <graphics.Point object at 0x0000013E0D263668>, and I don't know how to determine the x-coordinate of the center from that output. This is my problem. I can't translate the .getCenter() output to Cartesian coordinates.
> 
> 
> 
>> The initial point won't change, but that's just where the circle was 
>> originally.
> 
>> Are you sure that it doesn't change? Have you printed out 
>> moving_circle.getCenter().getX() and moving_circle.getCenter().getY() 
>> and seen that they aren't changing?
> 
> Distinguish between the circle's center and the initial center point I declared. My program can output the former, but it's in a format that I don't understand: <graphics.Point object at 0x0000013E0D263668>.
> 
> As for the initial center point (I'll call it moving_circle_*initial*_center instead), it won't change at all throughout the program execution.
> 
> I need to know the x- and y-coordinates of moving_circle.getCenter() at any point in time. I can't use the center of the circle *before* it started moving, because that value is static (in other words, moving_circle_initial_center.getX() and moving_circle_initial_center.getY() never change).
> 
I have already told you how to get the x and y coordinates.

moving_circle.getCenter() returns the centre as a Point object.

That Point object has .getX() and .getY() methods, which return the x 
and y coordinates respectively.



More information about the Python-list mailing list