• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(438)  |  Call(416)  |  Derive(0)  |  Import(22)
hypot(x, y)

Return the Euclidean distance, sqrt(x*x + y*y).

src/s/h/shedskin-HEAD/examples/fysphun.py   shedskin(Download)
# (c) Alex P-B (chozabu@gmail.com) 
# license: http://creativecommons.org/licenses/by-nc-sa/2.5/
 
from math import sin, cos, pi, hypot
from random import random
 
def setup(w, h):
def twopoint(p1,p2,destdist = 15,mult = 0.5):
	xd = p1.x-p2.x
	yd = p1.y-p2.y
	td = hypot(xd, yd)#+0.0000000001
	rads = p1.rad+p2.rad
	diffd = (destdist-td)*mult
	xd/=td
	l.p2 = p2
	xd = p1.x-p2.x
	yd = p1.y-p2.y
	dist = hypot(xd,yd)
	l.dist = dist
	l.strength = strength
	l.drawme = drawlinks

src/r/a/Rabbyt-0.8.3/examples/bezier.py   Rabbyt(Download)
from math import hypot
 
import pygame
import rabbyt
 
rabbyt.init_display((640,480))
rabbyt.set_viewport((640,480), projection=(0,0,640,480))
                running=False
        elif event.type == pygame.MOUSEBUTTONDOWN:
            for c in control_points:
                if hypot(c.x-event.pos[0], c.y-event.pos[1]) < 20:
                    grabbed_point = c
                    break
        elif event.type == pygame.MOUSEMOTION:

src/p/y/pyobjc-framework-Cocoa-2.3/Examples/AppKit/FieldGraph/fieldMath.py   pyobjc-framework-Cocoa(Download)
from math import pi, sin, cos, hypot, sqrt
 
# Math functions
 
def degToRad(deg):
    return (deg/180.0)*pi
 

src/u/n/uniconvertor-HEAD/UniConvertor/trunk/uniconvertor/src/app/Graphics/pattern.py   uniconvertor(Download)
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	USA
 
import math
from math import atan2, hypot, pi, sin, cos
 
from app import Point, Rotation, Translation, Trafo, NullPoint, NullUndo
 
		cx, cy = self.center
		cx = cx * rect.right + (1 - cx) * rect.left
		cy = cy * rect.top   + (1 - cy) * rect.bottom
		radius = max(hypot(rect.left - cx, rect.top - cy),
						hypot(rect.right - cx, rect.top - cy),
						hypot(rect.right - cx, rect.bottom - cy),
						hypot(rect.left - cx, rect.bottom - cy))
	def execute_radial(self, device, rect):
		cx, cy = self.center
		cx = cx * rect.right + (1 - cx) * rect.left
		cy = cy * rect.top   + (1 - cy) * rect.bottom
		radius = max(hypot(rect.left - cx, rect.top - cy),
						hypot(rect.right - cx, rect.top - cy),
						hypot(rect.right - cx, rect.bottom - cy),
						hypot(rect.left - cx, rect.bottom - cy))
		vx, vy = self.direction
		angle = atan2(vy, vx)
		rot = Rotation(angle, cx, cy)
		radius = max(hypot(left - cx, top - cy),
						hypot(right - cx, top - cy),
						hypot(right - cx, bottom - cy),
						hypot(left-cx,bottom-cy)) + 10

src/b/i/biskit-HEAD/trunk/Biskit/mathUtils.py   biskit(Download)
 
    Author: Victor Gil
    """ 
    from math import hypot, atan2, pi 
    if deg: 
        return hypot(x, y), 180.0 * atan2(y, x) / pi 
    else: 
        return hypot(x, y), atan2(y, x) 

src/b/i/biskit-HEAD/Biskit/mathUtils.py   biskit(Download)
 
    Author: Victor Gil
    """ 
    from math import hypot, atan2, pi 
    if deg: 
        return hypot(x, y), 180.0 * atan2(y, x) / pi 
    else: 
        return hypot(x, y), atan2(y, x) 

src/g/o/godot-HEAD/godot/component/recipes.py   godot(Download)
""" William Park, 'Simple Recipes in Python', March 1999 """
 
from math import pow, hypot, atan2, pi, sqrt, cos
import cmath
 
def cbrt(x):
    """ cbrt(x) = x^{1/3},  if x &gt;= 0
    """
 
    if deg:
        return hypot(x, y), 180.0 * atan2(y, x) / pi
    else:
        return hypot(x, y), atan2(y, x)
 

src/d/x/dxfwrite-0.3.5/dxfwrite/vector2d.py   dxfwrite(Download)
2d vector math module
"""
 
from math import hypot, atan2, sin, cos
 
def vector2d(vector):
    """ return a 2d vector """
def magnitude(vector):
    """ length of a 2d vector """
    return hypot(vector[0], vector[1])
 
def unit_vector(vector):
    """ 2d unit vector """
    return vdiv_scalar(vector, magnitude(vector))
def distance(point1, point2):
    """ calc distance between two 2d points """
    return hypot(point1[0]-point2[0], point1[1]-point2[1])
 
def midpoint(point1, point2):
    """ calc midpoint between point1 and point2 """
    return ((point1[0]+point2[0])*.5, (point1[1]+point2[1])*.5)

src/g/o/Godot-0.1.1/godot/component/recipes.py   Godot(Download)
""" William Park, 'Simple Recipes in Python', March 1999 """
 
from math import pow, hypot, atan2, pi, sqrt, cos
import cmath
 
def cbrt(x):
    """ cbrt(x) = x^{1/3},  if x &gt;= 0
    """
 
    if deg:
        return hypot(x, y), 180.0 * atan2(y, x) / pi
    else:
        return hypot(x, y), atan2(y, x)
 

src/u/n/uniconvertor-HEAD/UniConvertor/trunk/uniconvertor/src/app/Graphics/ellipse.py   uniconvertor(Download)
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	USA
 
from math import sin, cos, atan2, hypot, pi, fmod, floor
 
from app.conf.const import ArcArc, ArcChord, ArcPieSlice, ConstraintMask, \
		AlternateMask
	def Info(self):
		trafo = self.trafo
		w = hypot(trafo.m11, trafo.m21)
		h = hypot(trafo.m12, trafo.m22)
		dict = {'center': trafo.offset(), 'radius': w, 'axes': (w, h)}
		if w == h:
			text = _("Circle radius %(radius)[length], "

  1 | 2 | 3  Next