## Adding Genymotion Emulator to Android Studio

#### Instructions:

It’s very easy compared to adding other stuffs.

3. Next go to File -> Settings -> Plugins -> Browse Repositories.
4. Now in the search box, search for Genymotion and download the plugin.
5. If android studio prompts to restart then do it.
6. Now if you go to File -> Settings -> Other Settings -> Genymotion.
7. Here set the folder where you installed genymotion. In my case its set like this,

9. You also should have an icon like this after installing the plugin,

11. Press that button and Genymotion device manager will open. Note you can also open genymotion application from its executable from start or shortcut etc to install more virtual devices.

15. That is it. Hopefully the setup went correctly.

## C++ Code for finding Parametric Equation and Vector form for Line L through two points p1 and p2

#### Description:

Given two points $P_1 (x_1, y_1, z_1)$ and $P_2 (x_2, y_2, z_2)$ we are to find the parametric equation and vector form of line through these points.

The parallel vector to the line is, $\overrightarrow{P_1 P_2} = < x_2 - x_1, y_2 - y_1, z_2 - z_1 >$

So the parallel vector of $P_1 (2, 4, -1)$ and $P_2 (5, 0, 7)$ is, $\overrightarrow{P_1 P_2} = < 5 - 2, 0 - 4, 7 - (-1) > = < 3, -4, 8 >$

Note that $\vec{v}$ is the parallel vector. We know, $\vec{r} = \vec{r_0} + t \vec{v}$

where, $\vec{r} = < x, y, z >$ $\vec{r_0} = < x_0, y_0, z_0 >$ $\vec{v} = < a, b, c >$

So the vector equation form is, $\vec{r} = \vec{r_0} + t \vec{v}$ $< x, y, z > = < x_0, y_0, z_0 > + t < a, b, c >$

Also the parametric form is, $x = x_0 + at$ $y = y_0 + bt$ $z = z_0 + ct$

Now we can use either vector from origin to $P_1$ or origin to $P_2$. Here the vector from origin to  origin to $P_1$ which is (0, 0, 0) to (2, 4, -1) is, $\vec{r_0} = < 2 - 0, 4 - 0, -1 - 0 > = < 2, 4, -1 >$

So the vector equation of line through $P_1$ and $P_2$ is, $< x, y, z > = < 2, 4, -1 > + t < 3, -4, 8 >$

calculating further, $< x, y, z > = < 2, 4, -1 > + < 3t, -4t, 8t >$ $< x, y, z > = < 2 + 3t, 4 - 4t, -1 + 8t >$

Finally, $L: x = 2 + 3t, y = 4 - 4t, z = -1 + 8t$

Similarly the equation of the line can found out using origin to $P_2$.

### Code:

/**
* @author  Quickgrid ( Asif Ahmed )
* Problem: Find parametric equations for the line through p1 and p2.
*          Also for the segment joining these points.
*/

#include<stdio.h>

struct myVector{
int x, y, z;
} v1, v2;

void input2dPoints(){
printf("Enter p1:");
scanf("%d %d", &v1.x, &v1.y);
printf("Enter p2:");
scanf("%d %d", &v2.x, &v2.y);
}

void input3dPoints(){
printf("Enter p1:");
scanf("%d %d %d", &v1.x, &v1.y, &v1.z);
printf("Enter p2:");
scanf("%d %d %d", &v2.x, &v2.y, &v2.z);
}

struct myVector calculateParallelVector(int choice){
if(choice == 1)
return {v2.x - v1.x, v2.y - v1.y};
else{
return {v2.x - v1.x, v2.y - v1.y, v2.z - v1.z};
}
};

void printParametricAndVectorForm(int point, struct myVector mv, struct myVector parallelVector){
printf("Taking point p%d(%d, %d) on the line L we get parametric equation:\n", point, mv.x, mv.y);
printf("L: x = %d + %dt, y = %d + %dt\n",  mv.x, parallelVector.x, mv.y, parallelVector.y);
printf("\n");
printf("Vector form:\n");
printf("<x, y> = <%d, %d> + t <%d, %d>\n",  mv.x, mv.y, parallelVector.x, parallelVector.y);
printf("\n\n");
}

//@Override
void printParametricAndVectorForm(int point, struct myVector mv, struct myVector parallelVector, int dimension){
printf("Taking point p%d(%d, %d, %d) on the line L we get parametric equation:\n", point, mv.x, mv.y, mv.z);
printf("L: x = %d + %dt, y = %d + %dt, z = %d + %dt\n",  mv.x, parallelVector.x, mv.y, parallelVector.y, mv.z, parallelVector.z);
printf("\n");
printf("Vector form:\n");
printf("<x, y, z> = <%d, %d, %d> + t <%d, %d, %d>\n",  mv.x, mv.y, mv.z, parallelVector.x, parallelVector.y, parallelVector.z);
printf("\n\n");
}

int main(){
int choice;
struct myVector parallelVector;

printf("1. Two Dimensional.\n");
printf("2. Three Dimensional.\n");
printf("\nChoice: ");
scanf("%d", &choice);
printf("\n");

switch(choice){
case 1:
input2dPoints();

printf("\n");
parallelVector = calculateParallelVector(choice);
printf("Parallel vector -> p1p2 to the line L is: <%d, %d>\n", parallelVector.x, parallelVector.y);
printf("\n\n");

printParametricAndVectorForm(1, v1, parallelVector);
printParametricAndVectorForm(2, v2, parallelVector);

break;

case 2:
input3dPoints();

printf("\n");
parallelVector = calculateParallelVector(choice);
printf("Parallel vector -> p1p2 to the line L is: <%d, %d, %d>\n", parallelVector.x, parallelVector.y, parallelVector.z);
printf("\n\n");

printParametricAndVectorForm(1, v1, parallelVector, 3);
printParametricAndVectorForm(2, v2, parallelVector, 3);

break;

default:
printf("Wrong input.\n");
}

return 0;
}


## A small fix for the pain of Hyper-V and Intel Haxm in Windows 8.1

#### Some gibberish:

Trying to work on visual studio and android studio at the same time in the same machine is a great pain. By working at the same time i mean use both applications without rebooting the computer. It is possible to have hyper-v enabled and test a windows phone app, also run an android system image. But the problem is that we can not run the faster x86 or x86_64 system images. The only option is to use ARM system images which are really slow.

So it is possible to work in visual studio and make a windows or windows phone app. Also run android apps simultaneously without reboot if one doesn’t care about poor performance of ARM system images.

If we want to work in both android and windows platform we have to make a little sacrifice to work faster. The solutions here can used to run faster x86 or x86_64 system images. We can open both android studio and visual studio, write code but can not run / test them simultaneously.

#### Possible Solutions:

As far as i know it is not yet possible to run an x86 or x86_64 system images using HAXM in a Hyper-V enabled machine since both use hardware virtualization. In order to use x86 or x86_64 system images there are a few methods such as,

1. Have hyper-v disabled permanently if you only work on android.
2. Temporarily disable hyper-v by preventing it from running in startup.
3. Create a separate boot entry in which the previous one is hyper-v enabled and in the new boot entry is hyper-v disabled. ( I am using this 3rd method )

#### Hyper-V can’t be turned on Or, Haxm can’t be installed:

For those who are getting error messages and can not enable or install hyper-v or haxm hardware virtualization can be a cause. Hardware visualization must be enabled by the user first to use these technologies. It is enabled by default in most supported machines. If it is turned off then it needs to be enabled in the BIOS. This is also one cause for not being able to use virtual box.

### Installing Haxm in a Hyper-V enabled Machine:

##### Temporarily or, Permanently disable Hyper-V: ( Not recommended )

Follow this tutorial to temporarily or permanently disable hyper-v. Use with caution.

##### Create a separate boot entry in which the previous one is hyper-v enabled and in the new boot entry is hyper-v is disabled from startup:

Follow this msdn tutorial or, this tutorial by Scott Hanselman to create a separate boot entry for installing Haxm. Haxm can not be installed in the hyper-v enabled boot entry but in the new boot entry with hyper-v disabled Haxm can be installed.

#### Windows phone XDE emulator and Android Emulator with ARM image working at the same time: Here the ARM system image is an old Android 2.3.3 gingerbread since all my new system images are either x86 or x86_64.