# \#math

**URL:** https://discourse.threejs.org/tag/math/431.md?match_all_tags=true&page=1&tags%5B%5D=math

[Latest](https://discourse.threejs.org/latest.md) · [Categories](https://discourse.threejs.org/categories.md) · [Tags](https://discourse.threejs.org/tags.md)

**Page:** 2

---

## [How can I apply a transformation to the position attribute values in a mesh?](https://discourse.threejs.org/t/how-can-i-apply-a-transformation-to-the-position-attribute-values-in-a-mesh/60421)

<div class="topic-metadata">

**Author:** [@leo2](https://discourse.threejs.org/u/leo2)\
**Replies:** 2\
**Last updated:** [January 17, 2024, 2:42pm UTC](https://discourse.threejs.org/t/how-can-i-apply-a-transformation-to-the-position-attribute-values-in-a-mesh/60421 "2024-01-17T14:42:09Z")

</div>

I have a mesh that is loaded from an stl file and displayed in a scene. I have to do calculations using the vertices of this mesh in another coordinate space. I need to apply a transformation to those vertices. I clon…

---

## [Comparing two vectors](https://discourse.threejs.org/t/comparing-two-vectors/12106)

<div class="topic-metadata">

**Author:** [@Pigfarmer](https://discourse.threejs.org/u/Pigfarmer)\
**Replies:** 3\
**Last updated:** [January 16, 2020, 5:43am UTC](https://discourse.threejs.org/t/comparing-two-vectors/12106 "2020-01-16T05:43:36Z")

</div>

Hello! I’m new to Three.js and would like to create a Dual N’Back style game in 3D. One aspect of the game is pressing a button when the object appears in the same location it did x number of rounds ago and I was just wo…

---

## [Find the closest grid vertex to the mouse position](https://discourse.threejs.org/t/find-the-closest-grid-vertex-to-the-mouse-position/59838)

<div class="topic-metadata">

**Author:** [@birdblue0311](https://discourse.threejs.org/u/birdblue0311)\
**Replies:** 1\
**Last updated:** [January 2, 2024, 3:05am UTC](https://discourse.threejs.org/t/find-the-closest-grid-vertex-to-the-mouse-position/59838 "2024-01-02T03:05:50Z")

</div>

I’m trying to figure out how to find the closest grid vertex to the mouse cursor position. Let’s say I have a threejs gridHelper on which I want to implement a drawing of a polyline with “snapping” functionality . When h…

---

## [ThreeJS expert open position Startup Israel](https://discourse.threejs.org/t/threejs-expert-open-position-startup-israel/59828)

<div class="topic-metadata">

**Author:** [@jontabet](https://discourse.threejs.org/u/jontabet)\
**Replies:** 0\
**Last updated:** [January 1, 2024, 4:37pm UTC](https://discourse.threejs.org/t/threejs-expert-open-position-startup-israel/59828 "2024-01-01T16:37:22Z")

</div>

Hi, I am looking for a Three.js expert based in Israel. if you are interested, send me your CV : jonathan.tabet1@gmail.com Regards

---

## [OnChangeCallback for Vectors?](https://discourse.threejs.org/t/onchangecallback-for-vectors/59592)

<div class="topic-metadata">

**Author:** [@Harold](https://discourse.threejs.org/u/Harold)\
**Replies:** 11\
**Last updated:** [December 25, 2023, 12:51pm UTC](https://discourse.threejs.org/t/onchangecallback-for-vectors/59592 "2023-12-25T12:51:51Z")

</div>

Hi guys, I have a need to track changes in vectors in my code to keep certain things in sync between threads. I’m currently using my own Vector and Matrix implementations to emit “change” events whenever something chang…

---

## [How does TransformControlsPlane work?](https://discourse.threejs.org/t/how-does-transformcontrolsplane-work/29887)

<div class="topic-metadata">

**Author:** [@tobiascornille](https://discourse.threejs.org/u/tobiascornille)\
**Replies:** 4\
**Last updated:** [May 3, 2023, 2:41pm UTC](https://discourse.threejs.org/t/how-does-transformcontrolsplane-work/29887 "2023-05-03T14:41:11Z")

</div>

I’m trying to adapt TransformControls to scale a box by dragging on the faces (see images). My attempt kind of works, but with some starting positions, the box scales in the wrong direction, or suddenly scales way…

---

## [Math problem! Moving objects along the Z-axis](https://discourse.threejs.org/t/math-problem-moving-objects-along-the-z-axis/59311)

<div class="topic-metadata">

**Author:** [@Prometheus3636](https://discourse.threejs.org/u/Prometheus3636)\
**Replies:** 2\
**Last updated:** [December 17, 2023, 3:40pm UTC](https://discourse.threejs.org/t/math-problem-moving-objects-along-the-z-axis/59311 "2023-12-17T15:40:54Z")

</div>

In the following jsfiddle, I made a slider (at the bottom of the screen) that lets you move the displayed images back and forth along the z-axis: While I purposely positioned all the images a different amount of dista…

---

## [Are Spherical coordinates flipped?](https://discourse.threejs.org/t/are-spherical-coordinates-flipped/58467)

<div class="topic-metadata">

**Author:** [@nameo9283](https://discourse.threejs.org/u/nameo9283)\
**Replies:** 15\
**Last updated:** [November 24, 2023, 2:39pm UTC](https://discourse.threejs.org/t/are-spherical-coordinates-flipped/58467 "2023-11-24T14:39:15Z")

</div>

Q: Are Spherical coordinates theta and phi flipped in Vector3 source code? Im walking through class Spherical https://threejs.org/docs/?q=spher#api/en/math/Spherical And getting the results back to a position vector f…

---

## [Raycasting for determining the position of the 3d object on the detected Posnet 2d pixel coordinates of human body from webcam](https://discourse.threejs.org/t/raycasting-for-determining-the-position-of-the-3d-object-on-the-detected-posnet-2d-pixel-coordinates-of-human-body-from-webcam/58412)

<div class="topic-metadata">

**Author:** [@Shahzeen\_Ahmad](https://discourse.threejs.org/u/Shahzeen_Ahmad)\
**Replies:** 0\
**Last updated:** [November 21, 2023, 12:49pm UTC](https://discourse.threejs.org/t/raycasting-for-determining-the-position-of-the-3d-object-on-the-detected-posnet-2d-pixel-coordinates-of-human-body-from-webcam/58412 "2023-11-21T12:49:18Z")

</div>

I have calculated a midpoint between the right and left shoulder of the human body detected through a webcam using Posnet. the detected coordinates are 2D pixel coordinates I need to find the exact location of the 3d dre…

---

## [Convert Latitude / Longitude to Tube Geometry](https://discourse.threejs.org/t/convert-latitude-longitude-to-tube-geometry/58264)

<div class="topic-metadata">

**Author:** [@Garreta11](https://discourse.threejs.org/u/Garreta11)\
**Replies:** 3\
**Last updated:** [November 20, 2023, 12:10pm UTC](https://discourse.threejs.org/t/convert-latitude-longitude-to-tube-geometry/58264 "2023-11-20T12:10:52Z")

</div>

Hi, I have a JSON file with many coordinates (latitude, longitude, and elevation). These coordinates are very close together on the map, meaning that the values don’t change much. What I want to do is draw a TubeGeomet…

---

## [Convert webcam pixel coordinates to 3d vector](https://discourse.threejs.org/t/convert-webcam-pixel-coordinates-to-3d-vector/58224)

<div class="topic-metadata">

**Author:** [@Shahzeen\_Ahmad](https://discourse.threejs.org/u/Shahzeen_Ahmad)\
**Replies:** 1\
**Last updated:** [November 16, 2023, 5:38pm UTC](https://discourse.threejs.org/t/convert-webcam-pixel-coordinates-to-3d-vector/58224 "2023-11-16T17:38:22Z")

</div>

Position a 3D dress model onto the center of left and right shoulder key points detected from the pose model. Hi, I detect human body pose from a webcam using TensorFlow pose. I want to place my 3d dress in the center o…

---

## [Matrix4 to CSS matrix3d without CSSRenderer](https://discourse.threejs.org/t/matrix4-to-css-matrix3d-without-cssrenderer/58016)

<div class="topic-metadata">

**Author:** [@Kilroymyboy](https://discourse.threejs.org/u/Kilroymyboy)\
**Replies:** 2\
**Last updated:** [November 11, 2023, 8:49am UTC](https://discourse.threejs.org/t/matrix4-to-css-matrix3d-without-cssrenderer/58016 "2023-11-11T08:49:06Z")

</div>

I’m currently trying to take a Object3D and convert it’s matrix to a CSS matrix3d so the CSS is on top of 3D object. The reason I don’t want to use CSSRenderer is because we’re hooking these elements into react and need …

---

## [Set plane orientation](https://discourse.threejs.org/t/set-plane-orientation/57768)

<div class="topic-metadata">

**Author:** [@Tibi](https://discourse.threejs.org/u/Tibi)\
**Replies:** 6\
**Last updated:** [November 6, 2023, 2:16am UTC](https://discourse.threejs.org/t/set-plane-orientation/57768 "2023-11-06T02:16:14Z")

</div>

I have an issue with setting a plane orientation to the face normal direction in local space. I am using a raycaster to get an intersection point and the intersection face normals, using I am adding a plane in the mesh …

---

## [Jiggle Bone Physics Spring Damper](https://discourse.threejs.org/t/jiggle-bone-physics-spring-damper/57783)

<div class="topic-metadata">

**Author:** [@xenonpn](https://discourse.threejs.org/u/xenonpn)\
**Replies:** 1\
**Last updated:** [November 5, 2023, 3:57pm UTC](https://discourse.threejs.org/t/jiggle-bone-physics-spring-damper/57783 "2023-11-05T15:57:07Z")

</div>

It applies spring damper physics to bone animation of gltf object, however it does so for all bones of gltf, I tried modifying ZboingZboingPhysics.js to make it apply physics only to specified bones while other bones s…

---

## [Get plane face normal](https://discourse.threejs.org/t/get-plane-face-normal/57756)

<div class="topic-metadata">

**Author:** [@Tibi](https://discourse.threejs.org/u/Tibi)\
**Replies:** 4\
**Last updated:** [November 5, 2023, 7:49am UTC](https://discourse.threejs.org/t/get-plane-face-normal/57756 "2023-11-05T07:49:42Z")

</div>

How can I get a Plane Face normals without a raycaster, is it possible? It is a simple plane… const geometry = new THREE.PlaneGeometry( 1, 1 ); const material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THRE…

---

## [Vertex Shader Sphere Projection and CPU Distance Calculation](https://discourse.threejs.org/t/vertex-shader-sphere-projection-and-cpu-distance-calculation/56270)

<div class="topic-metadata">

**Author:** [@michealmyers81](https://discourse.threejs.org/u/michealmyers81)\
**Replies:** 19\
**Last updated:** [October 17, 2023, 11:26am UTC](https://discourse.threejs.org/t/vertex-shader-sphere-projection-and-cpu-distance-calculation/56270 "2023-10-17T11:26:32Z")

</div>

I have multiple planes whose vertices are transformed to a position on a sphere in the vertex shader. The GLSL function called pointToSphere transforms a point p to a position on a sphere with a radius of 100 units cente…

---

## [How to Convert Vector3 to Vector2?](https://discourse.threejs.org/t/how-to-convert-vector3-to-vector2/55935)

<div class="topic-metadata">

**Author:** [@Mohammad\_Shabani](https://discourse.threejs.org/u/Mohammad_Shabani)\
**Replies:** 8\
**Last updated:** [September 12, 2023, 5:04pm UTC](https://discourse.threejs.org/t/how-to-convert-vector3-to-vector2/55935 "2023-09-12T17:04:49Z")

</div>

Hi, I use Raycaster to get the coordinates of the point that the user clicks on. These coordinates are created through the following code: const intersects = raycaster.intersectObjects(scene.children); const p = interse…

---

## [How can I calculate area?](https://discourse.threejs.org/t/how-can-i-calculate-area/55896)

<div class="topic-metadata">

**Author:** [@syusri](https://discourse.threejs.org/u/syusri)\
**Replies:** 6\
**Last updated:** [September 11, 2023, 5:35pm UTC](https://discourse.threejs.org/t/how-can-i-calculate-area/55896 "2023-09-11T17:35:30Z")

</div>

Hi, I’m quite new to Three.js and React Three Fiber. I’m doing a project that involves two models, cutting through those models with a cutplane, creating caps and then finding the total area of the cap. While this isn’t …

---

## [The Same Quaternion But .angleTo Self Is Not Zero](https://discourse.threejs.org/t/the-same-quaternion-but-angleto-self-is-not-zero/55584)

<div class="topic-metadata">

**Author:** [@ShiHongyu](https://discourse.threejs.org/u/ShiHongyu)\
**Replies:** 3\
**Last updated:** [September 1, 2023, 8:45am UTC](https://discourse.threejs.org/t/the-same-quaternion-but-angleto-self-is-not-zero/55584 "2023-09-01T08:45:06Z")

</div>

When I use the Quaternion.rotateTowards() to animate camera, like this: function moving(dt) { timer += dt q1.rotateTowards(q2, dt \* turnRate \* speed) scope.camera.position.set(0, 0, 1).applyQuatern…

---

## [How to transform vector3 by angle?](https://discourse.threejs.org/t/how-to-transform-vector3-by-angle/55532)

<div class="topic-metadata">

**Author:** [@senior](https://discourse.threejs.org/u/senior)\
**Replies:** 1\
**Last updated:** [August 30, 2023, 3:35pm UTC](https://discourse.threejs.org/t/how-to-transform-vector3-by-angle/55532 "2023-08-30T15:35:56Z")

</div>

Hi, I have question and I don’t know how to realize it. Let’s say I have 4 Vector3 and I want to increase each of them on the z-axis by 100 and at the same time keep the angle of these vectors (as in the picture). In oth…

---

## [3D portfolio website](https://discourse.threejs.org/t/3d-portfolio-website/55159)

<div class="topic-metadata">

**Author:** [@Prerna\_Mohan](https://discourse.threejs.org/u/Prerna_Mohan)\
**Replies:** 4\
**Last updated:** [August 19, 2023, 7:45pm UTC](https://discourse.threejs.org/t/3d-portfolio-website/55159 "2023-08-19T19:45:23Z")

</div>

Hi everyone, This is my portfolio that I worked on during weekends. It showcases just some of my mini projects. I modelled my own sculpture using blender which was difficult but I managed to learn a lot. Then I learnt …

---

## [Weird lerp rotation behavior](https://discourse.threejs.org/t/weird-lerp-rotation-behavior/54588)

<div class="topic-metadata">

**Author:** [@dlk](https://discourse.threejs.org/u/dlk)\
**Replies:** 3\
**Last updated:** [August 15, 2023, 4:53pm UTC](https://discourse.threejs.org/t/weird-lerp-rotation-behavior/54588 "2023-08-15T16:53:02Z")

</div>

I’m working on my player controller with R3F and Rapier, and I’m trying to handle rotations the following way to make them smooth: if (leftward) { const targetRotation = Math.atan2(cameraDirection.z, -cameraDirectio…

---

## [When center point, start point, and end point are given](https://discourse.threejs.org/t/when-center-point-start-point-and-end-point-are-given/54886)

<div class="topic-metadata">

**Author:** [@1\_1](https://discourse.threejs.org/u/1_1)\
**Replies:** 1\
**Last updated:** [August 15, 2023, 3:23pm UTC](https://discourse.threejs.org/t/when-center-point-start-point-and-end-point-are-given/54886 "2023-08-15T15:23:16Z")

</div>

When center point, start point, and end point are given, how can we find startPoint, startangle, endPoint, and endAngle? I can’t remember if Three.js has a built-in feature or not.

---

## [Triangle containsPoint has a bug](https://discourse.threejs.org/t/triangle-containspoint-has-a-bug/54906)

<div class="topic-metadata">

**Author:** [@bbmv](https://discourse.threejs.org/u/bbmv)\
**Replies:** 4\
**Last updated:** [August 13, 2023, 8:18pm UTC](https://discourse.threejs.org/t/triangle-containspoint-has-a-bug/54906 "2023-08-13T20:18:22Z")

</div>

Hi guys! It seems the ‘containsPoint’ method of the ‘Triangle’ class isn’t working correctly. It returns true instead of false. See the example: https://jsfiddle.net/bbmv\_/edsq419m/11/

---

## [Need help in building arch based on distance between 2 objects and angle](https://discourse.threejs.org/t/need-help-in-building-arch-based-on-distance-between-2-objects-and-angle/54910)

<div class="topic-metadata">

**Author:** [@jayeomer](https://discourse.threejs.org/u/jayeomer)\
**Replies:** 7\
**Last updated:** [August 13, 2023, 4:54pm UTC](https://discourse.threejs.org/t/need-help-in-building-arch-based-on-distance-between-2-objects-and-angle/54910 "2023-08-13T16:54:27Z")

</div>

Hi I have 2 bars on each side, position and sizes are dynamic, I need to build and arch on top of these bars joining like yellow highlightes in the picture below, I must go with dynamically provide slope in a function a…

---

## [How to draw a triangle given two points?](https://discourse.threejs.org/t/how-to-draw-a-triangle-given-two-points/54522)

<div class="topic-metadata">

**Author:** [@1\_1](https://discourse.threejs.org/u/1_1)\
**Replies:** 3\
**Last updated:** [August 2, 2023, 7:21am UTC](https://discourse.threejs.org/t/how-to-draw-a-triangle-given-two-points/54522 "2023-08-02T07:21:27Z")

</div>

I want to draw a triangle given the center and end points. Any advice on maths please?

---

## [Logic to attach two objects via a rope](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614)

<div class="topic-metadata">

**Author:** [@Liron\_Toledo](https://discourse.threejs.org/u/Liron_Toledo)\
**Replies:** 6\
**Last updated:** [July 30, 2023, 1:09pm UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614 "2023-07-30T13:09:39Z")

</div>

Hi all! I had an idea that i wanted to try implement in my app but not sure about the best way to go about it. I want to try and connect one object (lets call it A) to another object (lets call it B) by an invisible rope…

---

## [My recent projects! Electric fields, wave equation, and chaos](https://discourse.threejs.org/t/my-recent-projects-electric-fields-wave-equation-and-chaos/54397)

<div class="topic-metadata">

**Author:** [@kritb](https://discourse.threejs.org/u/kritb)\
**Replies:** 4\
**Last updated:** [July 29, 2023, 10:57pm UTC](https://discourse.threejs.org/t/my-recent-projects-electric-fields-wave-equation-and-chaos/54397 "2023-07-29T22:57:33Z")

</div>

Models the divergence of a static electric filed. New divergence values form the color map after being solved. Would like to include a Laplacian solver and curl solver. FDM solves for wave approximation. Would like the …

---

## [Found incorrectly working methods .intersectBox(), .intersectPlane() for determining the intersection point of THREE.Ray](https://discourse.threejs.org/t/found-incorrectly-working-methods-intersectbox-intersectplane-for-determining-the-intersection-point-of-three-ray/54265)

<div class="topic-metadata">

**Author:** [@aset\_rahmgaliev](https://discourse.threejs.org/u/aset_rahmgaliev)\
**Replies:** 5\
**Last updated:** [July 28, 2023, 2:26am UTC](https://discourse.threejs.org/t/found-incorrectly-working-methods-intersectbox-intersectplane-for-determining-the-intersection-point-of-three-ray/54265 "2023-07-28T02:26:16Z")

</div>

found incorrectly working methods .intersectBox(), .intersectPlane() for determining the intersection point of THREE.Ray coordinates of origin points: pos2{“x”: 928.7828190673121, “y”: 39.71493452167897, “z”: -940.4438…

---

## [What is the correct way to move the Plane?](https://discourse.threejs.org/t/what-is-the-correct-way-to-move-the-plane/54191)

<div class="topic-metadata">

**Author:** [@heh](https://discourse.threejs.org/u/heh)\
**Replies:** 2\
**Last updated:** [July 23, 2023, 12:53pm UTC](https://discourse.threejs.org/t/what-is-the-correct-way-to-move-the-plane/54191 "2023-07-23T12:53:50Z")

</div>

In the example below, I have four planes whose position should be tied to the scroll. I don’t understand how to properly move the left and right side after I rotated them. Codeimport \* as THREE from 'three'; co…

[Previous page](https://discourse.threejs.org/tag/math/431.md?match_all_tags=true&tags%5B%5D=math)

[Next page](https://discourse.threejs.org/tag/math/431.md?match_all_tags=true&page=2&tags%5B%5D=math)
