Sin wave display(card game)

hello! I’m trying to make a hand display, where cards are displayed in a curve around a point. the problem is, i need the sin wave from 0-180, which would curve around the object this is attached to. however, set to 0-180, it instead gives me the full graph of 0-360.varibles in the code: (maxHandSize = 10, hand = List, hand.count=10), x and y hand scale are set to .1 and 1 respectively

  //using this object as a focus point, display the hand
void OnGUI()
{
    List<PointF> coords = new List<PointF>();
    coords = getPoints(0, 180, maxHandSize, 1f);
    if (hand.Count > 0)
    {
        for (int i = 0; i < hand.Count; i++)
        {
            if (i % 2 == 0 || i == 0|| true)
            {

                hand.ElementAt(i).transform.position = new Vector3(xHandScacle*(this.transform.position.x + coords[i].X), Math.Abs(yHandScacle*(this.transform.position.y * coords[i].Y)), this.transform.position.z);
            }
            else 
            {
                
            }
        }
    }
}
  List<PointF> getPoints(float start, float end, int count, float ymax)
{
    List<PointF> points = new List<PointF>();
    float deltaX = (end - start) / count;

    for (int i = 0; i < count; i++)
    {
        float x = i * deltaX;
        
        float y = ymax + (float)Math.Sin(x *1) * ymax;
        Debug.Log(y);
        points.Add(new PointF(x, y));
    }
    return points;
}

i fixed it. sin is in radians. for any future veiwers

List<PointF> getPoints(float start, float end, int count, float ymax)
{
    List<PointF> points = new List<PointF>();
    float deltaX = (end - start) / (count-1);

    for (int i = 0; i < count; i++)
    {
        float angleDegrees = start + i * deltaX; 
        float angleRadians = angleDegrees * (float)Math.PI / 180f; 

        float x = angleDegrees; 
        float y = (float)Math.Sin(angleRadians) * ymax; 

        Debug.Log($"Angle: {angleDegrees}°, Sin: {y}");
        points.Add(new PointF(x, y));
    }
    return points;
}```
1 Like