Post Reply 
Assign a polygon (or any shape) to a variable and view it with Geometry App
01-03-2024, 01:29 AM
Post: #1
Assign a polygon (or any shape) to a variable and view it with Geometry App
Can anyone help me?

I'm trying to create a simple code that requires the input of a complex number and create a polygon with the real e imaginary parts, so I can view it with the Geometry App.

The following code kinda works, just for the input part...

EXPORT Polygon1;

EXPORT PolygonalDraw()
BEGIN

INPUT({{ComplexA,[3]}});

Polygon1:= polygon(
point(0,0),
point(0,RE(ComplexA)),
point(2*RE(ComplexA),
2*RE(ComplexA)),
point(RE(ComplexA),0));

END;

I was hopping that by running this, I can simply click the Plot button and it would be there...
Find all posts by this user
Quote this message in a reply
01-05-2024, 02:37 PM (This post was last modified: 01-05-2024 05:24 PM by roadrunner.)
Post: #2
RE: Assign a polygon (or any shape) to a variable and view it with Geometry App
You have to build the instruction you want as a string and store it in the Instruction variable. Here's an example:

Code:
#pragma mode( separator(.,;) integer(h32) )

EXPORT PolygonalDraw()
BEGIN
 LOCAL ComplexA,a,b,c,d;
 INPUT({{ComplexA,[3]}});
 point(0,0)▶a;
 point(0,RE(ComplexA))▶b;
 point(2*RE(ComplexA),
  2*RE(ComplexA))▶c;
 point(RE(ComplexA),0)▶d;
 "GA:= "+a+"; // c(FF000000) v(1) \nGB:= "+b+"; // c(FF000000) v(1) \nGC:= "+c+"; // c(FF000000) v(1) \nGD:= "+d+"; // c(FF000000) v(1) \nGE:= polygon(GA,GB,GC,GD); // c(FF000000) v(1) \n"▶Instruction;
 STARTVIEW(1);
END;

edit: Well you don't *have* to do it that way. There are many ways to do what you want, the example above is one of those.

-road
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)