  C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # orientate a 3d plane from 3 given points  » javascript » orientate a 3d plane from 3 given points

By : Alexey Malinovskyi
Date : November 14 2020, 04:51 PM
will be helpful for those in need To get the direction of the vector to orientate the plane, calculate the cross product of any of the 2 sides of the triangle
so, if your points are a, b, c code :
``````side1 = subVectors (a, b);
side2 = subVectors (a, c);
planeNormal = crossVectors (side1, side2);
`````` ## How can I project an arbitrary plane identified by 4 points onto a 2d plane?

By : Eyal Peleg
Date : March 29 2020, 07:55 AM
I wish did fix the issue. This is a special case of finding mappings between quadrilaterals that preserve straight lines. These are generally called homographic or projective transforms. Here, one of the quads is a square, so this is a popular special case. You can google these terms ("quad to quad", etc) to find explanations and code, but here are some for you.
Perspective Transform Estimation ## Randomly selecting points in a plane, with a higher probability of selection given to closer points

By : user3118512
Date : March 29 2020, 07:55 AM
I wish did fix the issue.
Assign a "weight" to each point by for instance computing 1 / distanceFromCurrent. ## Convert points from one image plane to another plane using OpenCV

By : Phillip Shentu
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Use a homographic transform, if you provide 4 well spaced points the transform produced by findHomography will be well suited to your needs. Then you can apply the transformation using perspectiveTransform. ## Rotate K coplanar points to a plane parallel to x,y plane

By : something
Date : March 29 2020, 07:55 AM
Hope this helps You need basis vectors X,Y,Z first. So let take the mid point A and two distant points to it B,C (not on single line) from your data set first. The X,Y should lie in the plane and Z should be normal to it so:
code :
``````X = B-A     // any non zero vector inside plane
X = X / |X| // unit in size

Y = C-A     // any non zero vector inside plane
(X.Y) != 0  // but not parallel to X !!!
Y = Y / |Y| // unit in size
``````
``````Z = X x Y   // cross product gives you perpendicular vector
Y = Z x X   // now all vectors are perpendicular and unit
``````
``````P(u,v) = A + u*X + v*Y
``````
``````u = ((P-A).X) = dot(P-A,X)
v = ((P-A).Y) = dot(P-A,Y)
`````` ## Find 4 points equidistant from a centroid in 3D space where all points lie on a predefined plane

By : vampire.sorceress
Date : March 29 2020, 07:55 AM
should help you out We need to find two vectors perpendicular to plane (the normal). We can do so by the following procedure:
Normalize plane Set a vector k = (1, 0, 0) Calculate math.abs(np.dot(k, plane)) If > 0.9 then set k = (0, 1, 0) Calculate a = np.cross(k, plane)) and b = np.cross(plane, a) You now have two vectors in the plane. You can get any points in the plane by adding some number times these two vectors and adding to centeroid If you want specific distances, you need to normalize a and b
code :
``````import numpy as np
import math

def normalize(a):
b = 1.0 / math.sqrt(np.sum(a ** 2))
return a * b

def circlePoints(r, N_points, plane=(1,1,1), centroid=(0,0,0)):
p = normalize(np.array(plane))
k = (1, 0, 0)
if math.fabs(np.dot(k, p)) > 0.9:
k = (0, 1, 0)
a = normalize(np.cross(k, p))
b = normalize(np.cross(p, a))
step = (np.pi * 2) / N_points
ang = [step * i for i in xrange(N_points)]
return [(np.array(centroid) + \
r * (math.cos(rot) * a + math.sin(rot) * b)) \
for rot in ang]

print circlePoints(10, 5, (1, 1, 1), (0, 0, 0))
`````` 