ARKit - Resize object along particular direction - swift

I want to resize an object along a specific direction in ARKit.
For example, there is a cube on a detected plane and I want to be able to resize the cube in X direction, Y direction and Z direction respectively. Does anyone know how to do this? Thanks.

Related

how to get mouse drag direction in unity

Hello guys I am building a 3D game that player can reshape something like slime with dragging it. the shaping part is alright and I do not have a problem with it.
I use mesh manipulation for shaping my object and I move all vertices within a specific radius of clicked position. but my vertices are moving toward its normal vector I figured that out I can move vertices toward mouse drag vector by just changing normal vectors.
so, here is my question how can I get mouse drag vector so I can change my normal vector to that?
also the player can rotate around X And Y Axis on my object and this makes this problem a little more difficult.
because for example if I see my object from this angle (270,0,0) if players drag mouse to right and down my object should Stretch to its -x Axis and -z Axis.

How to make unity transform axis look at specific direction

I have a hierarchy like this:
--gun
\--bullet
In unity3d and I want the bullets specific axis meet with the guns specific axis
like this:
Note the Bule(z axis)
And here is the gun's transform
And I want to rotate the ball's transform so that the Z axis of the ball coincides with the guns Y axis
like this:
So How could I do that? thanks
A simple LookAt should do the job :
bullet.transform.LookAt( bullet.transform.position + gun.transform.up ) ;
LookAt :
Rotates the transform so the forward vector points at the given world position.
You can specify an additional vector if you want the up vector of your transform to point to a specific direction.
I think using LookRotation might solve your issue.
bullet.transform.rotation = Quaternion.LookRotation(gun.transform.forward, gun.transform.up);
What this does is that it creates a rotation based on a forward and up vector. So you might want to set something different than what I have in my example, but hopefully you'll get the idea.

Best way to find the coordinates between two points?

So I'm trying to find the location between point A & B. Point A will be my phone and point be will be a dot on a small object. Point A is a point in the middle of my phone with an X/Y axis. Using the front facing camera on an iPhone, point B attached to the small object, moves into the cameras view. Point B will never be more than a foot away from point A at any time.
Is it possible to determine the exact coordinates of point B in relation to point A's X/Y axis (Within a millimeter or so)? Would a signal need to be sent between the two points, or would the camera be able to pick up point B and determine its coordinates on point A's X/Y axis?
I've attached an image below to hopefully explain what I am trying to describe a little better.
The coordinates of two points are A(-6, 0) and B(10, 4). Find the coordinates of the point C on the y-axis such that AC=BC.

How to calculate ios accelerometer horizontal plane

I am working on an IOS AR project, now i 've done with Camera, GPS with altitude, Compass heading but i can not get the right vector of gravity to draw the right horizontal plane. Please help me with my problem.
- Calculate horizontal plane and draw on the camera view. (And with altitude will be so good)
- Maybe project wll help me a lot.
Please help.
Thanks you very much.
Record some filtered accelerometer samples while not moving the device.
Compute the average of all those samples to get the down vector.
Vectors perpendicular to it make up the horizontal planes. Taking the dot product of the down vector with a vector along the Z axis (0,0,1) would allow you to figure out the angle of the screen relative to the horizon (see accelerometer axes)
I haven't tried this, but that would be my approach... hope it helps somehow

UIImage rotation axis

I want to rotate an image (UIImage) but can only do it from a default axis which is dead centre of the image ! as in Fig A. I want to move the axis to the centre of the x axis at the foot of the image as in Fig B. Can someone help me with this? I can only think of work arounds such as placing the image on an imaginary circle around the origin where the centre of the image would be where I position, then rotate the objects. This is too complicated and hopefully unneccessary. Imagine i want to place a number of images around a clock face with the origin in the centre where the clock hands originate, that's what I want to achieve. (The maths for doing this would also be appreciated).
(mid x axis and mid y axis).
Try using the view's underlying CALayer's anchorPoint property.
http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004500-CH1-SW36
I think you can do it by first rotating using CGContextRotateCTM and then shifting that center point to the point you want it to be by using CGContextTranslateCTM
Like rotate 90 degree first to right
then shift center(x,y) to newPoint((x- width/2), (y - height/2)) here width and height are of rotated image.
I hope this helps.