Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7066431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:04:53+00:00 2026-05-28T05:04:53+00:00

I need help. I have many variables, that I use in my Graphics[] command,

  • 0

I need help. I have many variables, that I use in my Graphics[] command, that are dependent of one variable (H in my example). I want to manipulate my graphic so that by changing value of H graphic changes accordingly. But it is not as easy as I’ve thought.

If you have any idea on how to acomplish this, I would be grateful.

 (*This variables are dependent on H that I want to change in
manipulate*)

R = 10;

\[Alpha] = ArcSin[H/R];

p = H/Tan[\[Alpha]];

n = 1.5;

\[Beta] = ArcSin[n Sin[\[Alpha]]];

\[Theta] = \[Beta] - \[Alpha];

l = H/Tan[\[Theta]];

(*This is the graphic I want to make manipulated*)

Graphics[{(*Incident ray*)Line[{{-2, H}, {p, H}}],(*Prism*)
  Circle[{0, 0}, R, {0, Pi/2}], 
  Line[{{0, 0}, {0, 10}}],(*Refracted ray*)
  Line[{{p, H}, {p + l, 0}}],(*Surface*)
  Line[{{0, 0}, {p + l + 10, 0}}]}]

Here’s one of my solutions but it’s really messy. What I did is just manually pluged in those values. Is there any more appropriate way to acomplish this:

R = 10;
n = 1.5;
Manipulate[
 Graphics[{(*Incident ray*)
   Line[{{-2, H}, {H/Tan[ArcSin[H/10]], H}}],(*Prism*)
   Circle[{0, 0}, R, {0, Pi/2}], 
   Line[{{0, 0}, {0, 10}}],(*Refracted ray*)
   Line[{{H/Tan[ArcSin[H/10]], 
      H}, {H/Tan[ArcSin[H/10]] + 
       H/Tan[ArcSin[n Sin[ArcSin[H/10]]] - ArcSin[H/10]], 
      0}}],(*Surface*)
   Line[{{0, 
      0}, {H/Tan[ArcSin[H/10]] + 
       H/Tan[ArcSin[n Sin[ArcSin[H/10]]] - ArcSin[H/10]] + 10, 
      0}}]}], {H, 0.0001, 10, Appearance -> "Labeled"}]

And also how to make my graphic not to change it’s size constantly. I want prism to have fixed size and incident ray to change its position (as it happens when H gets > 6.66 in my example above / this solution).

The question is maybe confusing, but if you try it in Mathematica, you’ll see what I want. Thank you for any suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:04:54+00:00Added an answer on May 28, 2026 at 5:04 am

    I think your solution is not bad in general, Mark already noticed in his reply. I loved simplicity of Mark’s solution too. Just for the sake of experiment I share my ideas too.

    1) It is always a good thing to localize your variables for a specific Manipulate, so their values do not leak and interfere with other dynamic content. It matters if you have additional computation in your notebook – they may start resetting each other.

    2) In this particular case if you try to get read of extra variables plugging expressions one into each other your equations became complicated and it is hard to see why they would fail some times. A bit of algebra with help of functions TrigExpand and FullSimplify may help to clarify that your variable H has limitations depending on refraction index value n (see below).

    3) If we are aware of point (2) we can make variable n dynamic too and link the value H to n (resetting upper bound of H) right in the controls definition, so always it should be H<10/n . If[..] is also necessary so the controls will not “pink”.

    4) If your formulas would depend on R we could also make R dynamic. But I do not have this information, so I localized R via concept of a “dummy“ control (ControlType -> None) – which is quite useful concept for Manipulate.

    5) Use PlotRange and ImageSize to stop jiggling of graphics

    6) Make it beautiful 😉

    These points would be important if you’d like, for example, to submit a Demonstration to the Wolfram Demonstration Project. If you are just playing around – I think yours and Mark’s solutions are very good.

    Thanks,
    Vitaliy

     Manipulate[If[H >= 10/n, H = 10/n - .0001]; Graphics[{
       {Red, Thick, Line[{{-2, H}, {Sqrt[100 - H^2], H}}]},
       {Blue, Opacity[.5], Disk[{0, 0}, R, {0, Pi/2}]},
       {Red, Thick, Line[{{Sqrt[100 - H^2], H}, 
        {(100 n)/(Sqrt[100 - H^2] n - Sqrt[100 - H^2 n^2]), 0}}]}},
      Axes -> True, PlotRange -> {{0, 30}, {0, 10}}, 
      ImageSize -> {600, 200}], {{R, 10}, ControlType -> None},
     {{n, 1.5, "Refraction"}, 1.001, 2, Appearance -> "Labeled"},
     {{H, 3, "Length"}, 0.0001, 10/n - .0001, Appearance -> "Labeled"}]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a regex call that I need help with. I haven't posted my
I have this JUnit test that I need help developing a Interface and Class
I have an interesting SQL problem that I need help with. Here is the
I need some help with defining a dynamic method. Basically, I have many classes
I need help with wcf service. i have a ajax-enabled wcf service: public class
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I need help with SEO Configurations in Joomla. I have been tasked to handle
I need help getting git extensions to run with msysgit. I have had bad
i have a problem, i'm working on a gallery php script and need help,
I have little snippet for validatin' my form. I need help to position the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.