Showing posts with label coordinates. Show all posts
Showing posts with label coordinates. Show all posts

Sunday, December 22, 2019

TI-84 Plus CE: Drawing an Isosceles Triangle

TI-84 Plus CE:  Drawing an Isosceles Triangle

Introduction



The program ISOTRI draws an isosceles triangle given the following:

The coordinates of the vertex (F,G). 

The length R, which is the length of the line segments from (F,G) to (A,B) and (F,G) to (C,D). 

The tilt angle, T, the tilt of the triangle.  The counterclockwise convention is used. 

The angle, θ,  between the line segments connecting (F,G) to (A,B) and (F,G) to (C,D). 

TI-84 Plus CE Program:  ISOTRI
(Version 5.3 or later required to use the string commands)

Note:  The degree angle inserted in the calculations allows for user to enter angles in degrees, regardless of calculator setting. 

"2019-12-06 EWS"
ClrHome
Disp "ISOC TRIANGLE"
Disp "(F,G):"
Prompt F,G
Input "LENGTH? ",R
Input "TILT?°",T
Input "ANGLE?°", θ
"("+toString(F)+","+toString(G)+")"→Str1
F+R cos(θ°+T°) → A
G+R sin(θ°+T°) → B
"("+toString(A)+","+toString(B)+")"→Str2
F+R cos(T°) → C
G+R sin(T°) → D
√((D-B)²+(C-A)²) → E
"("+toString(C)+","+toString(D)+")"→Str3
ClrHome
Disp "(F,G):"
Pause Str1
Disp "(A,B):"
Pause Str2
Disp "(C,D)"
Pause Str3
Disp "DIST (A,B)-(C,D):"
Pause E
"DRAW TRIANGLE"
ClrDraw
FnOff
BackgroundOn BLACK
Line(F,G,A,B,1,LTGRAY)
Line(F,G,C,D,1,LTGRAY)
Line(A,B,C,D,1,YELLOW)
Pt-On(F,G,2,ORANGE)
Pt-On(A,B,2,LTBLUE)
Pt-On(C,D,2,LTBLUE)
DispGraph

Examples

Example 1:

(F,G):  (1,1)
R = 6
T = 30°
θ = 60°



Example 2:

(F,G):  (-6,0)
R = 8
T = -10°
θ = 70°




Merry Christmas and Happy Holidays,

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author


Tuesday, February 6, 2018

HP Prime: Pixel Plot, How to Change Cartesian Coordinates to Pixels

HP Prime: Pixel Plot, How to Change Cartesian Coordinates to Pixels


Changing Cartesian Coordinates to Pixels

When running programs on the HP Prime, the screen has a pixel coordinate system of 320 x 220 (to allow room for soft menu keys). 



There are two ways to calculate to translate Cartesian coordinates to pixel coordinates on the HP Prime.  The easy way is to use the C→PX command. 

However, if you are working in custom made apps, C→PX may not work because the command requires that app has the Plot variables Xmin, Xmax, Ymin, and Ymax.  This will require a conversion formula.

Given a desired xmin, xmax, ymin, and ymax, the following formulas I use are:

Scaling: 
xs = (xmax – xmin)/320
ys = (ymax – ymin)/-220 = (ymin – ymax)/220

Conversion to pixels of coordinates (x,y):
xp = (x – xmin)/xs
yp = (y – ymax)/ys

HP Prime Program: PIXELPLOT

EXPORT PIXELPLOT()
BEGIN
// EWS 2014-02-04

LOCAL xm,ym,xp,yp,x,y;
LOCAL xn,yn,xs,ys;
LOCAL ya,ch,flag;
LOCAL fx;

// set color scheme
LOCAL col1,col2;
col1:={#BF00FFh,#7DF9FFh,
#00FF00h,#D4AF37h,#FF0000h};
col2:={#4B0082h,#000080h,
#228B22h,#C3B091h,#800000h};

// Radians
HAngle:=0;

INPUT({{fx,[2]},
xm,xn,ym,yn,
{ch,
{"Purple","Blue","Green",
"Gold","Red"}}},
"Pixel Plot Official",
{"f(x) string:",
"x-min: ","x-max: ",
"y-min: ","y-max: ",
"Color: "});

RECT_P(0);

// calulate the scale
xs:=(xn-xm)/320;
ys:=(yn-ym)/−220;

// drawing

// color choice
LOCAL c1,c2;
c1:=col1[ch];
c2:=col2[ch];

// axis information
LOCAL st1,st2;
st1:="x:["+xm+","+xn+"]";
st2:="y:["+ym+","+yn+"]";
TEXTOUT_P(st1,0,0,2,#C0C0C0h);
TEXTOUT_P(st2,0,20,2,#C0C0C0h);

// function
FOR x FROM xm TO xn STEP xs DO

// skip 0 for now
IF x==0 THEN
CONTINUE;
END;

// function
y:=EXPR(fx);

// point→pixel, plot
// only if y is real
IF TYPE(y)==0 THEN
xp:=(x-xm)/xs;
yp:=(y-yn)/ys;
PIXON_P(xp,yp,c1);
END;

END;

// freeze screen
FREEZE;

END;

Notes: 

1. You should not have to include the string characters for f(x) as they are included in the input.

2. Use the lowercase x.

3. The program errors if a plot reaches point where f(x) is not defined.  I put in a condition when f(x) is complex (for example, the square root of negative number) for the plot to skip that pixel.  However, I have not put error skipping conditions when it comes to ln(x) or 1/p(x) where p(x) is a polynomial.  However, the pixel at x=0 is skipped to hopefully alieve some problems.  Be sure your range is appropriate.

4. The program uses Radians angle mode (HAngle = 0).

5.  I chose to have a black background with five color options (purple, electric blue, green, gold, and red) just for fun. 

Examples

Example 1:  f(x) = 2.5*cos(x^2)



Example 2:  f(x) = √(x^2 – 6)



Example 3:  f(x) = e^(-x^2)



Eddie

This blog is property of Edward Shore, 2018.

Python: Drawing a Ring of Circles

Python: Drawing a Ring of Circles The goal: Draw a number of circles that revolve around the origin (0,0). The center of each circle i...