Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import random
- import fileinput
- x0 = 10
- y0 = 20
- z0 = 30
- max_len = 10
- def gen(x0, y0, z0, max_len, count, filename):
- zc = []
- xc = []
- yc = []
- for i in range(0,count):
- fi1 = math.pi * 2 * random.random()
- fi2 = math.pi * 2 * random.random()
- len = random.random() * max_len
- xc.append( x0 + len * math.cos(fi1) * math.sin(fi2) )
- yc.append( y0 + len * math.cos(fi1) * math.cos(fi2) )
- zc.append( z0 + len * math.sin(fi1) )
- with open(filename, 'w') as the_file:
- str = "X:===========================\n"
- str += xc.__str__().replace("[","").replace("]","\n").replace(", ","\n")
- str += "Y:===========================\n"
- str += yc.__str__().replace("[","").replace("]","\n").replace(", ","\n")
- str += "Z:===========================\n"
- str += zc.__str__().replace("[","").replace("]","").replace(", ","\n")
- the_file.write(str)
- gen(0, 0, 0, 20, 100, "result.txt")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement