Away3d in Flex calculates the distance between two points and the midpoint example between two points

Source: Internet
Author: User

In Away3d development, it is sometimes necessary to compute the distance or midpoint between two points (Vector3D). Suppose to have the following V1, v2 two coordinate points.

Distance between 1 and two points (length of segment)

var v1:vector3d = new Vector3D (0,0,0);
var v2:vector3d = new Vector3D (200,200,200);
var lenght:number = v1.subtract (v2). length; 346.41016151377545

Midpoint between 2, two points (midpoint of line)

var v1:vector3d = new Vector3D (0,0,0);
var v2:vector3d = new Vector3D (200,200,200);

Method 1
var v3:vector3d = new Vector3D (v1.x+v2.x)/2, (V1.Y+V2.Y)/2, (V1.Z+V2.Z)/2);

Method 2
var Temv:vector3d = V1.add (v2);
var v3:vector3d = new Vector3D (TEMV.X/2, TEMV.Y/2, TEMV.Z/2);

Well, the above is a small series for you to sort out an article on the calculation of two points (Vector3D) between the distance or midpoint of the example, I hope to help you oh.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.