<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Rotate OnlineMapsDrawingRect]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2280&amp;type=atom" />
	<updated>2024-12-27T13:33:25Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=2280</id>
		<entry>
			<title type="html"><![CDATA[Re: Rotate OnlineMapsDrawingRect]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9746#p9746" />
			<content type="html"><![CDATA[<p>@savvas_6 Thanks. This works for me.</p>]]></content>
			<author>
				<name><![CDATA[A1]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=3164</uri>
			</author>
			<updated>2024-12-27T13:33:25Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9746#p9746</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate OnlineMapsDrawingRect]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9625#p9625" />
			<content type="html"><![CDATA[<p>Hi A1. </p><p>Try the following code to rotate the Line.</p><div class="codebox"><pre><code>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&lt;Vector2&gt; originalPoints = line.points;

        // Create a list to store the rotated points
        List&lt;Vector2&gt; rotatedPoints = new List&lt;Vector2&gt;();

        // 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&#039;s points with the rotated points
        line.points = rotatedPoints;

        // Refresh the map to reflect the changes
        OnlineMaps.instance.Redraw();
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2024-08-23T14:09:06Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9625#p9625</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate OnlineMapsDrawingRect]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9624#p9624" />
			<content type="html"><![CDATA[<p>I noticed that for OnlineMapsDrawingLine has an option for&nbsp; followRelief = true, which it works great on 3D terrain. </p><p>Is there any possibility to make OnlineMapsDrawingRect and OnlineMapsDrawingPoly follow Relief? <br />I couldn&#039;t find any similar function in API Reference.</p><p>thanks</p>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2024-08-23T13:54:10Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9624#p9624</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate OnlineMapsDrawingRect]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9623#p9623" />
			<content type="html"><![CDATA[<p>Do you have a function to rotate clockwise a OnlineMapsDrawingPoly ?</p>]]></content>
			<author>
				<name><![CDATA[A1]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=3164</uri>
			</author>
			<updated>2024-08-23T09:16:00Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9623#p9623</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate OnlineMapsDrawingRect]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9566#p9566" />
			<content type="html"><![CDATA[<p>Thank you Alex.</p>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2024-06-12T13:36:07Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9566#p9566</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate OnlineMapsDrawingRect]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9565#p9565" />
			<content type="html"><![CDATA[<p>Thank you Alex.</p>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2024-06-12T12:42:00Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9565#p9565</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate OnlineMapsDrawingRect]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9561#p9561" />
			<content type="html"><![CDATA[<p>Hi. </p><p>No, you can&#039;t rotate the rectangle. Use OnlineMapsDrawingPoly instead.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2024-06-12T09:49:12Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9561#p9561</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Rotate OnlineMapsDrawingRect]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9558#p9558" />
			<content type="html"><![CDATA[<p>Hi is there any way to rotate a Rectangle on the map?</p><p>eg. rotate the Rectangle by 45 degrees.</p>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2024-06-11T13:19:39Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9558#p9558</id>
		</entry>
</feed>
