Does 3D point lies between 2 3D points - geometry

I just wonder how can I determine if a given 3D point lies on a line given by 2 points, and ALSO it lies between those 2 points?

Points a,b,c are collinear (all lie on a single line) if b-a,c-a are parallel, which is true iff the cross product (b-a) x (c-a) is zero. (That is, all three of its components are zero. You should probably actually permit them to be nonzero but very very small; exactly what that should mean will depend on your application.)
Given that points a,b,c are collinear, b lies between a and c iff the scalar product (b-a).(c-b) is positive. (Non-negative, if it's OK for b to be coincident with a or c.)

Related

Given Points on Coordinate Axis , Find number of Right Triangles

A few points are given on X axis and a few on Y axis , Find number of right triangles using the given points as vertices.
Your approach is nice, just avoid extensive checking.
Put coordinates in (hash)map to provide almost O(1) access.
For every a^2 factorize it and check for divisors (and complementary ones) in the map.
(there is no more than 2*a divisors for a^2)

What does the mathematical notation at SVG arc implementation notes F.6.5.4 --> F.6.5.6 mean?

https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
I'm thinking they're a cute notation for arctan2, but I'm not sure. But then reading the notes below the equations just makes me more confused.
F.6.5.6 is using a triple bar and not an equal sign. The first part of the equation is Theta 1 and the second part is Theta 2, and then the arc that sweeps between them is the delta Theta (I suppose that just how you do it with a matrix, comma, parenthesis, angle sign, triple bar notation -- but I couldn't find other examples).
Theta1 (F.6.5.5) and Theta2 (F.6.5.6 left hand side) are calculated with atan2.
In the notation used in F.6.5.4
the half arrows (some people use full arrows here) over u and v indicate that these are vectors, ie directional quantities. These are usually expressed as a list of real numbers indicating a movement along each of the principle directions, for example in the 2-dimensional cartesian plane, we may have a vector (1,1) which indicates movement up by one and right by one (movement at a 45 degree angle).
On the left of the equation, the strange little symbol indicates an angle, so that left hand side reads the angle between the vectors u and v.
On the right hand side, the dot indicates a dot product (the sum of the products of corresponding entries in the vectors), and the double-bar notation indicates the length of the vector (the square root of the dot product of the vector with itself - in 2 dimensions, this should remind you of the Pythagorean Theorem).
This is a standard formula intimately familiar to anybody who has studied linear algebra. Here is a wikihow article demonstrating the formula where you will see the same notation in use.
F.6.5.5 and F.6.5.6
are applying this formula using the vectors created from the given variables at the beginning of the section. The first formula defines θ1 as the angle between the first chosen vector and the right x-axis (the vector representing a movement of one unit to the right and no vertical movement) and the stated vector. The second formula finds the angle Δθ in a similar manner.
The triple bar is a congruence relation (read x ≡ y mod 3 as x congruent to y mod 3). When two things are congruent mod something it indicates that the remainders of the two are the same when divided by the other number. Thus 13 ≡ 6 mod 7 because both 6 and 13 leave a remainder of 6 when divided by 7.
The formula for Δθ is saying that this angle is equal to the value computed on the right when both are interpreted as an angle between 0 and 360 degrees.
This is not the same as using the atan2 function. atan2 is useful for computing the angle a single vector forms with the x-axis, but not when we need the angle between two vectors (without transforming the coordinate system first).

Find angles of polygon using only known distances

I've got a mesh of points, but simplified I've got 5 points with 2 being primary points.
All distances from A and B to any other points are known ( C, D, E ), but the distance from A and B is not known. Neither are the location of these points, only the distances. Although A can be considered the origin (0,0).
Is it possible to find the internal angles and then consequently the distance between point A and B.
Otherwise how would this scenario need to be modified in order to find this distance.
Or is there simply just not enough information known?
The actual scenario can have more points with distances from points A and B known, but I've just tried to simplify here.
No. Lets fix A at (0,0) and B along the horizontal axis. Each two leg pair ACB, AEB and ADB can flex its elbow joint to allow for any position of B along the horizontal axis.
Given an AB distance then all the angles and points are uniquely defined. But if AB is unknown then the shape can fold on itself.

Finding the intersection of 2 ray normals

I have 2 rays, defined by a common point and a direction vector and I want to find the point at which the normals of the 2 rays intersect at a given distance along the normals and the distance along the rays these normals start at.
So in this system, A is the common point of the two rays, B and C are the direction vectors, and D and E are the length of the normal vectors.
I want to find the three ? points.
Here's my idea
First, define a line that is parallel to the existing line, that is, through A oriented along vector B, but is offset by vector E.
Define a second line that is parallel to the existing line, that is, through A oriented alone vector C, but is offset by vector D.
Find the intersection of these two new lines, this should give you the topmost ? you are looking for.

Given 2 points how do I draw a line at a right angle to the line formed by the two points?

Idealy I want to supply a sequence of points and have a line drawn at a right angle at every point (starting at the second point).
The direction of each line would alternate, so if I happened to draw a curve cosisting of 6 points, a line of a given lenth would be drawn for each point starting with the second point, i.e 5 additional lines on alternating sides of the curve, a bit like a caterpillar with alternating legs.
(I understand that the lines won't be entirely at right angles to the curve but rather at right angle to the line formed by any two points on the curve).
It's a question of vector mathematics. You can calculate the directing vector between two points A and B by subtracting A from B. In 2D and only in 2D the vector right angled to this vector can be obtained by reversing x and y component and taking one component negative. If you negate the new x component you'll make a left turn, by negating y you'll make a right turn. You can then reduce the directing vector to unit size (= of length 1) by dividing each component by the length of the vector (sqrt(xx + yy)). Finally you can stretch the unit vector again by your desired length and have one of the size you want. If you add this vector to either A or B you'll get a point to which you want to draw your line.
Here's a little math help:
These are points A and B expressed as vector.
The directing vector is calculated by a simple subtraction.
The normal vector is given by flipping the directing vector, that is to reverse the components and make one component negative. nl = normal, flipped to the left, nr = normal, flipped to the right
The unit vector of the normal vector is given by dividing each component by the length of the vector.
Calculates the length of a vector
If you want to draw a line from B to the left (when coming from A) you calculate the point P to draw the line to as
So you want to alternate that one time you draw to the left and one time to the right when iterating over the points.
If you have points lying outside your canvas, then you length is probably too large. You can of course calculate the point at which the vector to P would cross the boundary by calculating the intersection point of the vector BP and the border.

Resources