Topic: Rotate OnlineMapsDrawingRect
Hi is there any way to rotate a Rectangle on the map?
eg. rotate the Rectangle by 45 degrees.
You are not logged in. Please login or register.
Infinity Code Forum → Online Maps Help → Rotate OnlineMapsDrawingRect
Hi is there any way to rotate a Rectangle on the map?
eg. rotate the Rectangle by 45 degrees.
Hi.
No, you can't rotate the rectangle. Use OnlineMapsDrawingPoly instead.
Thank you Alex.
Thank you Alex.
Do you have a function to rotate clockwise a OnlineMapsDrawingPoly ?
I noticed that for OnlineMapsDrawingLine has an option for followRelief = true, which it works great on 3D terrain.
Is there any possibility to make OnlineMapsDrawingRect and OnlineMapsDrawingPoly follow Relief?
I couldn't find any similar function in API Reference.
thanks
Hi A1.
Try the following code to rotate the Line.
using System.Collections.Generic;
using UnityEngine;
public class LineRotator
{
public static void RotateLine(OnlineMapsDrawingLine line, Vector2 pivot, float angleDegrees)
{
// Convert the rotation angle from degrees to radians
float angleRadians = angleDegrees * Mathf.Deg2Rad;
// Get the list of original points from the line
List<Vector2> originalPoints = line.points;
// Create a list to store the rotated points
List<Vector2> rotatedPoints = new List<Vector2>();
// Calculate the sine and cosine of the rotation angle
float cosTheta = Mathf.Cos(angleRadians);
float sinTheta = Mathf.Sin(angleRadians);
// Iterate over each point and apply the rotation
foreach (Vector2 point in originalPoints)
{
// Translate the point to the origin (pivot as the origin)
float translatedX = point.x - pivot.x;
float translatedY = point.y - pivot.y;
// Apply the rotation matrix
float rotatedX = translatedX * cosTheta - translatedY * sinTheta;
float rotatedY = translatedX * sinTheta + translatedY * cosTheta;
// Translate the point back
rotatedX += pivot.x;
rotatedY += pivot.y;
// Add the rotated point to the new points list
rotatedPoints.Add(new Vector2(rotatedX, rotatedY));
}
// Update the line's points with the rotated points
line.points = rotatedPoints;
// Refresh the map to reflect the changes
OnlineMaps.instance.Redraw();
}
}
@savvas_6 Thanks. This works for me.
Infinity Code Forum → Online Maps Help → Rotate OnlineMapsDrawingRect
Powered by PunBB, supported by Informer Technologies, Inc.