Python 查看turtle circle()图形中使用的所有坐标

Python 查看turtle circle()图形中使用的所有坐标,python,python-3.x,math,turtle-graphics,cartesian-coordinates,Python,Python 3.x,Math,Turtle Graphics,Cartesian Coordinates,我想画一条带氮基的DNA链:一小段,一个碱基,一小段,另一个碱基,依此类推。按这个顺序。 但是当你打断一个圆,在这个例子中是一个半圆,用来画其他东西的线,像是一条直线,它将是基础,圆的角度会改变。我想不出办法把它改回去 所以,更简单的方法是,画一个半圆,画一条线,然后继续画半圆,看起来就像转到一个坐标系,然后在那里画你想要的东西 但是要计算一个圆的所有精确坐标,对于每个不同的圆,如果我需要更多的话,需要很长的时间 有没有办法让turtle或任何其他东西/软件将我绘制/编码的圆的所有坐标作为输出返

我想画一条带氮基的DNA链:一小段,一个碱基,一小段,另一个碱基,依此类推。按这个顺序。 但是当你打断一个圆,在这个例子中是一个半圆,用来画其他东西的线,像是一条直线,它将是基础,圆的角度会改变。我想不出办法把它改回去

所以,更简单的方法是,画一个半圆,画一条线,然后继续画半圆,看起来就像转到一个坐标系,然后在那里画你想要的东西

但是要计算一个圆的所有精确坐标,对于每个不同的圆,如果我需要更多的话,需要很长的时间

有没有办法让turtle或任何其他东西/软件将我绘制/编码的圆的所有坐标作为输出返回

比如,如果我画这个圆圈:

海龟是否有可能返回制造它的坐标

下面是一个例子,我所说的创建一个只使用坐标的圆的意思:

from turtle import *

t = Turtle()

def got(x,y,d) :        # to use goto more easily
    t.penup()
    t.goto(x,y)
    t.pendown()
    t.seth(d)

x=0
y=0
d=0
megalist = [5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,-1,0,0,0,0,0-1,-1,-1,-1,-1,-1,-1,-1,-1,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,]

for i in megalist :
    x = x + i
    y= y +4
    got(x,y,d)
    t.forward(-1)
海龟是否有可能返回制造它的坐标

对。有一些*_poly方法,通常用于创建自定义游标,可用于执行您描述的操作:

from turtle import Screen, Turtle

screen = Screen()
turtle = Turtle(visible=False)
turtle.penup()

turtle.seth(45)

turtle.begin_poly()
turtle.circle(100, 90)
turtle.circle(-100, 90)
turtle.end_poly()

polygon = turtle.get_poly()

print(polygon)

for point in polygon:
    turtle.goto(point)
    turtle.pendown()

screen.exitonclick()
控制台输出

屏幕输出

当你打断一个圆圈时。。。画其他的东西,比如 直线…,圆的角度改变了。我不能思考 把它改回去的方法

我相信,您可以通过在小范围内循环来中断循环,保存位置和标题,进行绘图,并在下一次循环范围迭代之前恢复位置和标题。下面是一个简单的示例,它仅在图形本身放回位置时保存和恢复标题:

from turtle import Screen, Turtle

screen = Screen()

turtle = Turtle(visible=False)
turtle.speed('fastest')  # because I have no patience

turtle.setheading(45)

for extent in range(9):
    turtle.circle(100, 10)

    heading = turtle.heading()

    turtle.setheading(0)
    turtle.forward(10)
    turtle.backward(10)

    turtle.setheading(heading)

for extent in range(9):
    turtle.circle(-100, 10)

    heading = turtle.heading()

    turtle.setheading(180)
    turtle.forward(10)
    turtle.backward(10)

    turtle.setheading(heading)

screen.exitonclick()
屏幕输出


阿曼辛,你回答了这两个问题,谢谢!!两种方法都有效
> python3 test.py
((0.00,0.00), (13.96,17.51), (23.68,37.68), (28.66,59.51), (28.66,81.91),
(23.68,103.74), (13.96,123.91), (0.00,141.42), (-13.96,158.93),
(-23.68,179.10), (-28.66,200.94), (-28.66,223.33), (-23.68,245.16),
(-13.96,265.34), (0.00,282.84))
>
from turtle import Screen, Turtle

screen = Screen()

turtle = Turtle(visible=False)
turtle.speed('fastest')  # because I have no patience

turtle.setheading(45)

for extent in range(9):
    turtle.circle(100, 10)

    heading = turtle.heading()

    turtle.setheading(0)
    turtle.forward(10)
    turtle.backward(10)

    turtle.setheading(heading)

for extent in range(9):
    turtle.circle(-100, 10)

    heading = turtle.heading()

    turtle.setheading(180)
    turtle.forward(10)
    turtle.backward(10)

    turtle.setheading(heading)

screen.exitonclick()