Skip to content

Conversation

oqu
Copy link

@oqu oqu commented Oct 5, 2025

TL;DR #5209 is asking for more examples. This PR is for the example shapes_math_sine_cosine

Summary

Added a new example shapes_math_sine_cosine.c that demonstrates the relationship
between the unit circle and the sine / cosine functions. The example is a C port
of the p5.js "angles and motion: sine/cosine" demo and uses raylib for rendering
and raygui for a small control panel.

Key features:

  • Interactive animation of a point moving around a circle (uniform circular motion).
  • Sine (red) and Cosine (orange) graphs plotted below the circle.
  • Vertical tracker line and moving graph points synchronized with the circular motion.
  • Play / Pause control implemented with a raygui toggle.
  • Control panel positioned on the right side of the window.

Changelog

  • examples/shapes/shapes_math_sine_cosine.c — NEW: main example source
  • examples/shapes/shapes_math_sine_cosine.png — optional screenshot.

Possible areas of improvement

  • Make the circle and line thicker
  • Use constant for the menu layout

Tests

Manually tested on macos by building raylib, then building the example.

cd raylib/src
make -s

cd ../examples
make -s shapes/shapes_math_sine_cosine

Let me know if you need any changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant