dist()

Calculate the distance between 2 points

Example

Syntax

In two dimensions

dist(x1, y1, x2, y2)
InputDescription

x1

the x-coordinate of the first point

y1

the y-coordinate of the first point

x2

the x-coordinate of the second point

y2

the y-coordinate of the second point

In three dimensions

dist(x1, y1, x2, y2, z1, z2)
InputDescription

z1

the z-coordinate of the first point

z2

the z-coordinate of the second point

    text(round(dist(x1, y1, x2, y2)), 50, 50)
  sphere(dist(0, 0, 0, x, y, z))
  
  x+=3*noise(2*frameCount)*random([-1, 1])
  y+=4*noise(frameCount)*random([im-1, 1])
  z+=noise(0.5*frameCount)*random([-1, 1])

Description

Calculates the distance between two points, in either two or three dimensions. This uses the Euclidean distance, usually called the Pythagorean distance

Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!

We'd love to hear your Feedback/Comments here.

Last updated