- Prepare
- Mathematics
- Geometry
- Spheres
- Discussions

# Spheres

# Spheres

+ 0 comments How to move both the soheres in same directions ? online taweez for love

+ 0 comments was a bit annoying, that the code template didn't follow the input specification (4 lines pos1/acc1/pos2/acc2), however solution then was easy and straightforward...

def solve(r1, r2, pos1, acc1, pos2, acc2): # both spheres move on straight lines: pos + t^2/2 * acc # ... however doing a time transformation t' = t^2/2 this becomes pos + t' * acc # now center your coordinate system on sphere1: pos' = (pos-pos1) - t*acc1 # ... then sphere2 is moving along: (pos2-pos1) + t * (acc2-acc1) # either it moves away from sphere 1, or we have to check the nearest point vdiff = lambda v2,v1:[x2-x1 for x2,x1 in zip(v2,v1)] dot = lambda v1,v2:sum(x1*x2 for x1,x2 in zip(v1,v2)) pos = vdiff(pos2,pos1) acc = vdiff(acc2,acc1) # already in contact? if dot(pos,pos)<=(r1+r2)**2: return 'YES' # moving away? if dot(pos,acc)>=0: # not in contact now and ever return 'NO' # dropping the perpendicular from O on line: pos + t * acc t0 = - dot(pos,acc)/dot(acc,acc) perp = [p+t0*a for p,a in zip(pos,acc)] if dot(perp,perp)<=(r1+r2)**2: # check the distance return 'YES' else: return 'NO'

+ 0 comments I don't know what I do without you. ya wadoodo to attract someone

+ 0 comments The problem states that the two spheres are initially not in contact, but: For the first case, we can ignore the 0-valued Y and Z components of position and acceleration so that we have a 1-D problem where X1=0 and x2=-1. So, at time=0, the distance dc between the

*centers*of the two spheres is 1. However, the distance between the two sphere's outer surfaces is dc MINUS (r1+r2), or -2. Thus, the two spheres initially overlap (in fact, sphere 2 contains sphere 1). This contradicts the problem statement. Am I missing something?

+ 0 comments Pyhthon code worked, just had to take sqrt of discriminant as well. Not sure why it didn't worked in java

Sort 25 Discussions, By:

Please Login in order to post a comment