# Vec3

The Vec3 class represents a vector in 3D space. Here is how you initialize one and get values from it.

```let pos = new Vec3(2, 0, 0);
log(pos); // output: {2, 0, 0}
log(pos.x); // output: 2```

Here’s more examples of its usage.

```let a = new Vec3(1, 3, 5);
let b = new Vec3(3, 7, 9);
log(a);
let length = a.length();
let sqrLength = a.sqrLength(); //squared length
let normalized = a.normalize();
let diff = a.sub(b);
let dotProduct = a.dot(b);
let crossProduct = a.cross(b);
let distanceBetweenPoints = a.distance(b);

let factor = 2;
let scaled = a.scale(factor);

let alpha = 0.5;
let lerp = a.lerp(b, alpha);

let c = new Vec3(101, null, null);
let cxe = c.isXEmpty(); //false
let cye = c.isYEmpty(); //true
let cze = c.isZEmpty(); //true```
{"ft_lang_label":"__label__en","ft_lang_prob":0.68407303,"math_prob":0.99960726,"size":897,"snap":"2019-51-2020-05","text_gpt3_token_len":282,"char_repetition_ratio":0.15677492,"word_repetition_ratio":0.0,"special_character_ratio":0.35005575,"punctuation_ratio":0.25892857,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999976,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-20T01:55:00Z\",\"WARC-Record-ID\":\"<urn:uuid:b4815f24-4f51-4bb3-b4b0-cd2920a323bc>\",\"Content-Length\":\"154772\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:699790a8-dba8-4b10-a4be-d24ed10cb304>\",\"WARC-Concurrent-To\":\"<urn:uuid:e166915a-809d-48b5-8201-7ff257f0063d>\",\"WARC-IP-Address\":\"72.52.251.107\",\"WARC-Target-URI\":\"https://www.buildbox.com/help/buildbox-3-api-reference/helper-classes/vec3/\",\"WARC-Payload-Digest\":\"sha1:NFHMX5ITGAMNB3IZLGBZFHLSLLRTI3Z2\",\"WARC-Block-Digest\":\"sha1:MFCSVBGUMH3POVZESBAVGWFIUHRVNPEF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579250595787.7_warc_CC-MAIN-20200119234426-20200120022426-00163.warc.gz\"}"}