Trying to make life worth

Monday, July 24, 2017

Surprise . (Dot) in Gmail Id is not consider

Hi, Now a day Everyone has Email id with the different name like bhakar.(dot)38@gmail.com, bhakar.(dot)churu@gmail.com, bhakar.(dot)239@gmail.com etc. Have you ever notice that there is no meaning of  "." (Dot) in your email Id. You can log in without "."  (dot) like bhakar38@gmail.com. 
One Day I was trying to log in my Gmail id and My email id is bhakar.churu@gmail.com. I entered bhakarchuru@gmail.com and type password. It successfully log in. I noticed I forget to type "." (Dot) but its login

Enjoy without "." in your email id. 

Wednesday, December 14, 2016

How to Find Minimum Area Bounding Rectangle for given 3D Polygon ?

I have an arbitrary polygon as shown in Pic with co-planar Vertices's A,B,C,D,E,F,G,H in 3 D coordinate System. This Polygon is about to arbitrary axis.
Step 1. Rotate Arbitrary Polygon in X-Y Plane[Bounding-rectangle of 3D Polygon]
Step 2. Pick 1 edge and align this edge with the X axis(use Destination Vector " Vector3(1, 0, 0); // X-axis for align Edge Along X-axis " and Edge Direction as Source Vector. Compute Rotation Matrix and Save as EdgeAlignX-Axis Matrix to Rotate back Rectangle in Step 4). Use the min/max x,y to find the bounding rectangle. Compute Area and store in list, Do the same for remaining edges in  polygon. Pick the rectangle with the minimum Area.

Step 3.  Generate Minimum Bounding Rectangle by using min max.
bottomleftCorner = new Vector3(minXYZ[0], minXYZ[1], pointarr[0].z);
bottomRightCorner = new Vector3(maxXYZ[0], minXYZ[1], pointarr[0].z);
topLeftCorner = new Vector3(minXYZ[0], maxXYZ[1], pointarr[0].z);
topRightCorner = new Vector3(maxXYZ[0], maxXYZ[1], pointarr[0].z);

Note:- set Z-value of Bounding Rectangle Equal to Rotated Polygon Z Value for Perfect Align. Instead of Min Z and Max Z. 
Step 4. Rotate Computed Bounding rectangle Reverse of Edge Align X-Axis Matrix.

step 5.  rotate Bounding rectangle back to Original polygon direction by using reverse of Rotation matrix.








How to find Bounding Rectangle of 3D Polygon

I have an arbitrary polygon as shown in Pic with co-planar Vertices's A,B,C,D,E,F,G,H in 3 D coordinate System. This Polygon is about to arbitrary axis. 
1.Rotate this arbitrary polygon  in X-Y Axis. 

How to rotate Polygon from arbitrary Axis to X-Y Axis.

Compute normal of given Polygon. lets Assume normal of Polygon is Vector Nsrc.
Normal for any plane in X-Y axis will Z-direction so normal for X-Y Plane Vector Ndst (0,0,1).
By using Nsrc (source normal) and  Ndst(destination Normal) compute rotation matrix and rotate plane in X-Y Axis.

2. Compute Min-Max for Rotated Polygon. i. e minXYZ[] and maxXYZ[] and generate Bounding rectangle by using min max.
bottomleftCorner = new Vector3(minXYZ[0], minXYZ[1], pointarr[0].z);
bottomRightCorner = new Vector3(maxXYZ[0], minXYZ[1], pointarr[0].z);
topLeftCorner = new Vector3(minXYZ[0], maxXYZ[1], pointarr[0].z);
topRightCorner = new Vector3(maxXYZ[0], maxXYZ[1], pointarr[0].z);

Note:- set Z-value of Bounding Rectangle Equal to Rotated Polygon Z Value for Perfect Align. Instead of Min Z and Max Z. 
3.  rotate Bounding rectangle back to Original polygon direction by using reverse of Rotation matrix.


Bounding Rectangle

Sunday, December 11, 2016

How to sort 3D vertices of a polygon in order?

we are given multiple random coplanar 3D points. Compute normal by any 3 Point. we need to rotate all these point in X-Y plane. So compute rotation matrix normal to (0,0,1). rotate all these in X-Y plane.


      double[] normal = PlaneUtils.getNormal(tverts);
      Vector3 srcNormal = new Vector3(normal[0], normal[1], normal[2]).normalize();
      Vector3 destNormal = new Vector3(0, 0, 1);
      // Rotation Matrix of Arbitrary Polygon From Current Plane to XY Plane
      Matrix4 rotationMatrix = Matrix4.rotate(destNormal, srcNormal);

      for (int i = 0; i < PointArrVal.length; i++) {
        PointArrVal[i].timesEquals(rotationMatrix);
      }

Now Compute Mean of All X-coordinate and mean of All Y-coordinate.
Mean of X= Sum of All X-coordinate/number of Point and in same way compute mean of Y.

Compute Atan2 angle between Mean Point and given coordinate.

Math.atan2(clipCornerPoint[i].y - cY, clipCornerPoint[i].x - cX), clipCornerPoint[i]
Store computed angle with vertices in Ordered Multi Map like

TreeMap <Double, List<Point3>> multimap = new TreeMap<Double, List<Point3>>();
      for (int i = 0; i < clipCornerPoint.length; i++) {
        putObjects(multimap, Math.atan2(clipCornerPoint[i].y - cY, clipCornerPoint[i].x - cX), clipCornerPoint[i]);
      }

Sort map angle as key and it will give you vertices in order.
now reverse your point in same previous Arbitrary Axis by inverse Rotation Matrix.