How to find the target position of an arrowhelper in three.js? - three.js

I wish to add two arrows in the scene where the second arrowhelper's origin is the tip of the first arrowhelper. Cuurently I have direction, origin vector and length of first arrowhelper. How can I position the second arrowHelper on the tip of the first arrowHelper?

Related

Update position of Visual3D element when position of another Visual3D element changes

I am wondering how I could achieve this:
I have ModelVisual3D with 2 elements. First element is SphereVisual3D and second one is PipeVisual3D. When I change coordinates of Sphere I want that Pipe's Point1 property changes to the same value as sphere's center value.
Thanks in advance

Three JS find a point on plane knowing an origin point and the distance

I found the coordinates of the origin point from the intesection between a plane and a vector.
How can I find the coordinates of a second point on the plane knowing only the distance on the two axes that the second point should have

Aiming a 3D ray in space at a specific target by rotating a parent matrix

I've got a weird problem I've been trying to solve for a few days and I'm wondering if someone can help me out.
I have the following pieces of information:
A standard PSR (position, scale, and rotation) matrix
An origin point in 3D space defining the starting point of a ray
A normal vector in 3D space relative to #2 that defines the ray direction
A target point in 3D space
The ray origin and normal can be located anywhere in 3D space, but they must be parented to the matrix described in #1 (which itself can have any initial rotation and/or position within 3D space).
What I need to do is to calculate the rotation of the parent matrix to ensure that the ray origin and ray direction are aligned in such a way that the ray is guaranteed to intersect with the target point, preferably using an up vector for alignment if there is more than one possible solution.
Is there any straightforward way to calculate this?
EDIT:
Here's some pictures that show exactly what I'm trying to do. Apologies for the confusion!
In this picture, the orange cube represents the parent matrix (with no rotation), the yellow sphere represents the ray origin, and the blue arrow represents the ray direction. There's also an up vector and target point.
I need to rotate the matrix the ray origin and direction are parented to so that the ray points directly at the target object, with the ray origin falling on a 2D plane defined by the parent matrix position, target point, and up vector.
Here's a third example showing how the ray direction now points directly at the target point.
And finally here's another picture that roughly shows how the entire thing needs to be aligned with the up vector.
The primary problem here is that nothing is constant- the parent matrix offset (read: position) could change, or the ray origin and direction could change. The target point will also move around, as can the up vector- meaning that I need to figure out how to realign everything as the objects shift around in 3D space.

Rotate point in coordinate system around abitrary point

I want to rotate a rectangle in a coordinate system. I already know how to rotate each point in it around the 0,0 position, but what I want is to rotate the rectangle around it's minimum x,y point (bottom left, so to speak). I already tried "normalizing" the points first (to 0,0) and then adding the offset again, but my math seems to be faulty.
Two images to clarify. The red circle is the point around which the points in the retangle are rotated. The min (=minimum) point around which to rotate is at 2,1 (bottom left of the dark green rectangle)
First image: What I already can do.
Second image: What I want to accomplish

Photoshop smart object: get rotation angle via Applescript?

I have tried and failed to find an Applescript code that returns a smart object's current rotation angle in Photoshop. Anyone have an idea of where that property is listed? I'm beginning to think this feature isn't currently supported by Applescript.
In Photoshop, objects like a selection has no angle value, because it means nothing: if your selection is made by multiple segments making a complexe shape, there is no mathematical way you can define angle for that shape !
However, you can work with boundary rectangle (which includes that shape). You can rotate this complete boundary (i.e. the selection) and then you will get a new boundary (new rectangle where new rotated shape fits in).
A boundary rectangle is made of a list of for values :
top left corner horizontal position (X1)
top left corner vertical position (Y1)
bottom right corner horizontal position (X2)
bottom right corner vertical position (Y2)
Positions are real numbers, starting with border of canvas (not border of layer ! so you may have negative values). The units depends of the unit of measure of the document.
Once that's clear (I hope !) if you use mathematical calculation between initial boundary and new boundary, you can calculate the rotation angle:
(Pythagore triangle)
If you assume that initial rectangle borders were vertical and horizontal :
cosinus (Teta) = (X2-X1) / (X'2 - X'1)
Teta = angle you are looking for
X1, X2 are the positions of the boundary corners before rotation and X'1, X'2 are position of same corners after rotation.
Please note that this method is OK for selection (any shape), or layers.
It should also be OK for the full canvas, but I never test it for canvas.

Resources