# Help with trigonometry (finding position relative to object)

I don't know how to translate a position to it's relative position to an object's rotation and position.

I have created a script to move the sprite based on a stored x and y position. I do not know how to reverse this script and have it work for getting the relative position when I place it down.

The script on the bottom will accurately work as I rotate the map sprite I am using, but I have been unsuccesful in usung the position on the stage to create the 'x' and 'y' variables.
Custom block definitions:

Change y by cos(direction of sprite one) * the pixel length from the rotation point that you want the y anchored to
Do the same for x with sin(direction of sprite one) * the same pixel length.
You are changing the original point by these values, or, mathematics wise, adding these to the respective y and x of the original point.
Make sure you anchor it at 0 degrees to align it.
Edit: I haven't tried this equation in costume context yet, only for a costume that was specifically a line, but it should work just as well. If the equation only works in quadrant one (top left section relative to the sprite at 0 degrees) then make sure that Snap!'s degree system goes from 0->90->180->-90.
if not convert it to that so that x and y can be negative
Edit: Sorry for the lack of explanation, I was trying to hurry to leave for church. I am glad your problem was solved :).

Question: What are you trying to do?

With

Point on mini-map ("Sambar Map..." with properties direction=0, size=50) located at [0,50] has a World absolute coordinates ...

There is a project Username=dardoro&ProjectName=world2map to check the coordinate translation

Green rectangle is a mini-map, the stage is a "world".
The green dot is a point on mini-map following the mouse pointer.
The calculated "world" position is marked by a red dot.

Thankyou. Excellent way of displaying how it works, using the position over an unmoved plain also.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.