What is the difference between G41 and G42? - cnc

I am studying Cnc programming and I got stuck on the difference between G41 and G42. The lecturer didnt explain it clearly so Im looking for somebody who can give me a clearer explaination of the difference. I know they are both cutter compensation, but how do I know when to use G41 and when to use G42?

Its actually quite simple to determine the difference between G41 and G42. But if you get it wrong, It could be a really costly mistake. G41 compensates your cutter to the left, and G42 compensates your cutter to the right.
You can read more about it here:
Cutter compensation G40 G41 G42

I explain you in simple way G41 code is use for move cnc control tool left of the countering direction. G42 code is opposite than the G41. It can use for move cnc control tool right of the countering direction.

I've used G42 & G41 in wire edm work.use G42 as a work comp, usually.008“wire comp (meaning it's.008" from centerline of cutting path), to skim ID keyways on size. G41 is used for OD keyways and splines. So here's a real world example for the coding application.

Related

How should i make infinte ground ?

I'm trying to make a simplified version of crazy taxi . For the first step i need to make an infinite ground . I'VE searched online but couldn't find any examples .
Can i find any example of how to do this ?
https://www.youtube.com/watch?v=rhTPxrJICVg&list=PLLH3mUGkfFCXQcNBz_FZDpqJfQlupTznd
N3K makes an infinite runner in Subway Surfers style, meaning ground coming from the back and going towards the camera.
The above link is to his tutorial series.
This is a very broad question I try to give a very simplified answer to get you going.
To create endless road you need some sort of procedural function that generates corners for your track. If you do not need to backtrack you can cook something up yourself like (in X distance turn X degrees to the right). If you do need to backtrack you need something like perlin/simplex noise that always generates the same value based on 1 or more other values. You could use total distance to get the curve in the road.
You simply keep generating the world on the fly and unload pieces of the world you don't need any more. If the player can alter the world like destroying street furniture or leaving skitmarks you need to implement a chunk system. When you backtrack and generate a cerain part of the world with your procedural function you can have permanent changes the player made in that specific part by saving and loading to the chunk. Much like Minecraft does it actually.

Difference between Hand direction vs palm Normal

What is the difference between Hand.Direction and Hand.PalmNormal?
in the documentation, both methods have mentioned that "The direction is expressed as a unit vector pointing in the same direction as the directed line from the palm position to the fingers." what is the exact direction of the palm? is palm normal the normal vector of the direction?
Hand.Direction vs Hand.PalmNormal
Hand.Direction is like if you took a pencil and bridged the distance from the middle of your palm towards your fingers. Hand.PalmNormal would be if you took a pencil and put the eraser end of it flat on your palm, ignoring anything the fingers are doing.
To see for yourself, there is a demo you can check out. Also, here is a graphical depiction:

obstacle avoidance implementation in matlab

This could be a really broad question, but if you can help me with ideas, it would be a great help to me.
I am trying to implement basic path finding algorithm in matlab. I have to create a map where the robot can navigate and also avoid obstacles and reach destination. I have the algorithm fine with me. But am struggling with the gui as I haven't used much of Gui in matlab.
This is the following idea I had.
I created a plot and just defined 4 coods for each obstacle, destination as a circle and a start point. But am stuck when I think how I can detect whether the robot has hit an obstacle or not. One way is to create the equation of line and try to see if the point ever comes to lie on it. But the movement is based ona random generated variable. Thus it is possible for the robot to cross the line and get inside the polygon.
My apologies for bein too elaborate, but can you please tell me the best way to implement this in matlab? It is mandatory to do this in matlab. Please suggest me a better and easy way to program it. Thanks in advance.
If your obstacles are all polygons you could try to use the ray casting algorithm described on the following wikipedia site.
Point in polygon algorithm
With this you should be able to determine if the robot position lies within an obstacle, or you could determine if the next movement will bring the robot into contact with the obstacle.
If you are looking for a simple algorithm that can take care of obstacles inherently i would suggest the potential fields algorithm (can get stuck in certain cases)
Potential Fields
else you can also try the A* algorithm, which is better in my opinion; Good description of A*

Car crash simulation

I want to ask you How can I make simulation of car crash ?
On the internet I found http://www.gamedev.net/reference/articles/article1459.asp .
I think about using finite-element-method, but now I think it is too difficult for me :/
Do you know any good, not too accurate and not very hard-to-learn methods to simulate collision of two bodies ( two cubic cars ) with deforming?
My first idea was to made these cars with some number of rigid bodies, and connect them, but I don't know if it is good idea :/
Try reading this paper for starters. This and the references therein should point you in the right direction, more or less.

Drawing Routes with iPhone

I am trying to make an iPhone application which can draw a path between two points (similar to Google Maps) but instead of the map i want to use any other image as a background, this path between the two points might not be straight and there might be multiple paths to get from one point to another then I want to draw the shortest path between the two points.
I tried using the CGContext & CGPath but I got stacked.
Can you help me plz.
Thanx,
Ghaith
I think you're looking for UIBezierPath. You can add simple lines/polygons with something like:
UIBezierPath* path = [UIBezierPath bezierPath];
[aPath moveToPoint:CGPointMake(50.0, 50.0)];
[aPath addLineToPoint:CGPointMake(10.0, 10.0)];
[aPath addLineToPoint:CGPointMake(10.0, 50.0)];
[aPath closePath];
You can also, of course, add curves (bezier ones!) and other shapes. Then to draw it use the [aPath stroke] call in your view's drawRect method.
For more information see the iPad Programming Guide
This seems like a problem that's not really related to drawing the route.
You want to find the shortest path from one point to another, given certain criteria - where you can and cannot move, for example. I don't see this problem as something you can solve with drawing, but with actually calculating the different possible ways and then compare them. When you have decided which is the best route. Drawing is pretty simple.
How you would go by deciding I'm actually not sure - sorry 'bout that. But you should probably have a look at some shortest path algorithms. But that probably means you have to represent the underlying image as a pattern, or a series of nodes but graphical problems are not my cup of tea, so I'm not really sure how.
Just a side note - If the number of possible ways of getting from point A to point B are great, this can become a computational problem, and you have to make sure that the iPhone can manage.
(this should probably be a comment somewhere, but since I can't yet and I still wanted to share my two cents, it became an answer.)
Edit:
I just thought of really naive aproach! - for fun mostly, but I couldn't keep myself from posting.
Suppose you have a representation of the image. What parts can't be traveled on and what parts can be. Each pixel that can be travelled on is represented by a 1, and every other pixel is represented by a 0. Thus the pixels represented by 1s can be seen as nodes on which we can travel.
Each node can reach, at most, 8 other nodes - the adjacent pixels. And the weight of travelling between any two nodes could be set as 1. But we have to account that travelling in a diagonal is a greater distance so that weight should be sqrt(2).
Now we have a great bunch of nodes - each with weights in between them. From here we can apply a djikstra-algorithm to find the best route. (maybe some other algorithm is more beneficial at this point - but djikstras is the only one I'm familiar with).
hum, wonder how bad of a solution this would be. ... again, you probably don't want this solution...
EDIT 2:
I will say this again that this is probably not the best way to do this! You should seriously ask someone with more experience in algorithms and in graphical problems. - This was something I thought of at 3am and was mostly for laughs.
If your question is about calculating routes instead of drawing routes, that's a whole different problem. The standard algorithm for finding efficient routes through a given space are the "A*" (pronounced A-star) algorithms, which are typically what real-time strategy games use when you click a unit and tell it to "go there". It's also got many uses in AI when searching for a transition through a space.
It's not easy to get right, though. It might be easier to find a good game engine that already includes an A* implementation and integrate that into your software.