eukleides-1.5.4.orig/0000755000175000017500000000000011365502244014652 5ustar robertlerobertleeukleides-1.5.4.orig/Changelog0000644000175000017500000000320511365502244016464 0ustar robertlerobertle1.5.4 Bug with labels in euktopst fixed. Printing of null values improved. Fixed formating of PSTricks output for conics. 1.5.3 Local scale parameter bug corrected. Fixed bug concerning 'and' and 'or' operators. Added examples in contrib. Moved po to contrib/po. Added keyword localization for German. 1.5.2 Implemented optional drawing step for conics. Changed back install-info into ginstall-info in doc/Makefile. Wrote win32 replacements for euktotex and euktopdf. Fixed basename determination in euktotex and euktopdf. Added readline replacement for win builds. Changed rindex into strrchr in eukleides/check.c. 1.5.1 Documentation revised and updated. Changed ginstall-info into install-info in doc/Makefile. Line-set intersection bug fixed. Suppressed libintl dependency when no locale is selected. Bug with byte code instruction JPZ on x64 platforms fixed. Byte code debugging implemented. Nested functions suppressed. Line drawing bug corrected. Problem with printing of null values fixed. Bug with point on segment fixed. Problem with formating of \pspolygon in PSTricks output fixed. Long option name --local changed to --locale, bug with argument fixed. Optional step value in for loops added. Default locus point number changed to 120. Bug with homothetic circles and conics fixed. Problem with output command fixed. Installation directory problem in doc/Makefile and man/Makefile fixed. Local scale parameter bug for strings and hatches fixed. Flag -lcurses changed to -lncurses in build/Makefile. Flex invocation problem in build/Makefile fixed. Bug with segment drawing in euktopst fixed. 1.5.0 Initial release. eukleides-1.5.4.orig/Makefile0000644000175000017500000000450611365502244016317 0ustar robertlerobertle# Eukleides main makefile # Copyright (c) Christian Obrecht 2004-2010 include Config MAKEC = $(MAKE) --no-print-directory -C LOC := $(strip $(LOCALES)) INSTALL_BINARIES := $(addsuffix .install,$(BINARIES)) all: bin loc doc man bin: $(BINARIES) $(BINARIES): @echo "Making $@" @export BINARY=$@ && $(MAKEC) build loc: ifneq ($(LOC),) @echo "Making locales" @$(MAKEC) contrib/po endif doc: loc_doc @echo "Making documentation" @$(MAKEC) doc loc_doc: ifneq ($(LOC),) @echo "Making locales documentation" @$(MAKEC) contrib/po documentation endif .PHONY: man man: @echo "Compressing man pages" @$(MAKEC) man install: $(INSTALL_BINARIES) install_scr install_tex install_loc install_doc \ install_man install_exm $(INSTALL_BINARIES): @export BINARY=$(basename $@) && $(MAKEC) build install install_scr: @echo "Installing scripts" @install bash/* $(BIN_DIR) install_tex: @echo "Installing TeX files" @install -d $(TEX_DIR) @install -m 0644 tex/* $(TEX_DIR) @mktexlsr 2> /dev/null install_loc: ifneq ($(LOC),) @echo "Installing locales" @$(MAKEC) contrib/po install endif install_doc: @echo "Installing documentation" @$(MAKEC) doc install ifneq ($(LOC),) @$(MAKEC) contrib/po install_doc endif install_exm: @echo "Installing examples" @install -d $(EXM_DIR) @install -m 0644 contrib/examples/* $(EXM_DIR) install_man: @echo "Installing man pages" @$(MAKEC) man install uninstall: uninstall_bin uninstall_scr uninstall_tex uninstall_loc \ uninstall_doc uninstall_man uninstall_bin: @echo "Uninstalling binaries" @$(MAKEC) build uninstall uninstall_scr: @echo "Uninstalling scripts" @$(RM) $(addprefix $(BIN_DIR)/,$(notdir $(wildcard bash/*))) uninstall_tex: @echo "Uninstalling TeX files" @$(RM) -r $(TEX_DIR) @mktexlsr 2> /dev/null uninstall_loc: ifneq ($(LOC),) @echo "Uninstalling locales" @$(MAKEC) contrib/po uninstall endif uninstall_doc: @echo "Uninstalling documentation" @$(MAKEC) doc uninstall uninstall_man: @echo "Uninstalling man pages" @$(MAKEC) man uninstall clean: clean_bin clean_loc clean_doc clean_man clean_bin: @echo "Cleaning binaries" @$(MAKEC) build clean clean_loc: ifneq ($(LOC),) @echo "Cleaning locales" @$(MAKEC) contrib/po clean endif clean_doc: @echo "Cleaning documentation" @$(MAKEC) doc clean clean_man: @echo "Cleaning man pages" @$(MAKEC) man clean eukleides-1.5.4.orig/COPYING0000644000175000017500000010451311365502244015711 0ustar robertlerobertle GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . eukleides-1.5.4.orig/src/0000755000175000017500000000000011365502244015441 5ustar robertlerobertleeukleides-1.5.4.orig/src/common/0000755000175000017500000000000011365502244016731 5ustar robertlerobertleeukleides-1.5.4.orig/src/common/utils.h0000644000175000017500000000273211365502244020246 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DTOR(x) M_PI*(x)/180 #define RTOD(x) 180*(x)/M_PI #define EPSILON 1e-12 #define ZERO(x) fabs(x) < EPSILON #define EQL(x, y) fabs((x)-(y)) < EPSILON #define NEQL(x, y) fabs((x)-(y)) >= EPSILON double Sin(double x); double Cos(double x); double Tan(double x); double Asin(double x); double Acos(double x); double Atan(double x); double det2(double a, double b, double c, double d); double det3(double a, double b, double c, double d, double e, double f, double g, double h, double i); double Clamp(double x, double y, double z); double distance(_point *A, _point *B); double argument(_point *A, _point *B); double principal(double x); _point *get_point(_set **set); eukleides-1.5.4.orig/src/common/point.c0000644000175000017500000001502511365502244020231 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "conic.h" #include "utils.h" #include "parser.tab.h" void create_point_cartesian(void) { _point *val; get_mem(val, _point); val->y = POPn; val->x = POPn; PSH(val); } void create_point_polar(void) { double r, a; _point *val; get_mem(val, _point); a = POPn; r = POPn; val->x = r*Cos(a); val->y = r*Sin(a); PSH(val); } void create_point_on_segment(void) { double x; _set *set; _point *A, *B; _point *val; x = POPn; set = POP(_set); A = get_point(&set); B = get_point(&set); get_mem(val, _point); val->x = A->x + x*(B->x - A->x); val->y = A->y + x*(B->y - A->y); PSH(val); } void create_point_on_line(void) { double x; _line *l; _point *val; x = POPn; l = POP(_line); get_mem(val, _point); val->x = l->x + x*Cos(l->a); val->y = l->y + x*Sin(l->a); PSH(val); } void create_point_with_abscissa(void) { double x, c; _line *l; _point *val; x = POPn; l = POP(_line); c = Cos(l->a); if (ZERO(c)) runtime_error(_("invalid line")); get_mem(val, _point); val->x = x; val->y = l->y + (x-l->x)*Sin(l->a)/c; PSH(val); } void create_point_with_ordinate(void) { double y, s; _line *l; _point *val; y = POPn; l = POP(_line); s = Sin(l->a); if (ZERO(s)) runtime_error(_("invalid line")); get_mem(val, _point); val->x = l->x + (y-l->y)*Cos(l->a)/s; val->y = y; PSH(val); } void create_point_on_circle(void) { double a; _circle *c; _point *val; a = POPn; c = POP(_circle); get_mem(val, _point); val->x = c->x + c->r*Cos(a); val->y = c->y + c->r*Sin(a); PSH(val); } void create_point_on_conic(void) { _conic *C; _point *val; double c, s, t; t = POPn; C = POP(_conic); c = Cos(C->d); s = Sin(C->d); get_mem(val, _point); switch (C->type) { case ELLIPSE: parametric_ellipse(&(val->x), &(val->y), t, C->x, C->y, C->a, C->b, c, s); break; case HYPERBOLA: if (t <= -180 || t >= 180 || t == 0) runtime_error("invalid argument"); parametric_hyperbola(&(val->x), &(val->y), t, C->x, C->y, C->a, C->b, c, s); break; case PARABOLA: if (t <= -180 || t >= 180) runtime_error("invalid argument"); parametric_parabola(&(val->x), &(val->y), t, C->x, C->y, C->a, c, s); break; } PSH(val); } void create_midpoint(void) { _set *set; _point *A, *B; _point *val; set = POP(_set); A = get_point(&set); B = get_point(&set); get_mem(val, _point); val->x = (A->x + B->x)/2; val->y = (A->y + B->y)/2; PSH(val); } void create_isobarycenter(void) { int n = 0; _set *set; _point *val; set = POP(_set); if (set == NULL) runtime_error(_("empty set")); get_mem(val, _point); val->x = 0; val->y = 0; do { val->x += set->p->x; val->y += set->p->y; n++; set = set->next; } while (set != NULL); val->x /= n; val->y /= n; PSH(val); } void create_barycenter(void) { double c, s = 0; _point *cur, *val; get_mem(val, _point); val->x = 0; val->y = 0; c = POPn; cur = POP(_point); do { val->x += c*cur->x; val->y += c*cur->y; s += c; c = POPn; cur = POP(_point); } while (cur != NULL); val->x /= s; val->y /= s; PSH(val); } #define cosine(a, b, c) (b*b + c*c - a*a)/(2*b*c) #define tangent(x) sqrt(1-x*x)/x void create_orthocenter(void) { _point *A, *B, *C, *val; double a, b, c, ca, cb, cc, d; C = POP(_point); B = POP(_point); A = POP(_point); get_mem(val, _point); a = distance(B, C); b = distance(C, A); c = distance(A, B); if (ZERO(a) || ZERO(b) || ZERO(c)) runtime_error(_("invalid triangle")); ca = cosine(a, b, c); cb = cosine(b, c, a); cc = cosine(c, a, b); if (ca == 0) { ca = 1; cb = 0; cc = 0; } else if (cb == 0) { ca = 0; cb = 1; cc = 0; } else if (cc == 0) { ca = 0; cb = 0; cc = 1; } else { ca = tangent(ca); cb = tangent(cb); cc = tangent(cc); } d = ca + cb + cc; val->x = (ca*A->x + cb*B->x + cc*C->x)/d; val->y = (ca*A->y + cb*B->y + cc*C->y)/d; PSH(val); } void translate_point(void) { _point *A, *val; _vector *u; u = POP(_vector); A = POP(_point); get_mem(val, _point); val->x = A->x + u->x; val->y = A->y + u->y; PSH(val); } void reflect_point(void) { _point *A, *val; _line *l; double c, s, x, y, p; l = POP(_line); A = POP(_point); c = Cos(l->a); s = Sin(l->a); x = A->x - l->x; y = A->y - l->y; p = 2*(c*x + s*y); get_mem(val, _point); val->x = l->x + p*c - x; val->y = l->y + p*s - y; PSH(val); } void symetric_point(void) { _point *A, *O, *val; O = POP(_point); A = POP(_point); get_mem(val, _point); val->x = 2*O->x - A->x; val->y = 2*O->y - A->y; PSH(val); } void rotate_point(void) { _point *A, *O, *val; double a, c, s, x, y; a = POPn; O = POP(_point); A = POP(_point); c = Cos(a); s = Sin(a); x = A->x - O->x; y = A->y - O->y; get_mem(val, _point); val->x = O->x + c*x - s*y; val->y = O->y + s*x + c*y; PSH(val); } void homothetic_point(void) { _point *A, *O, *val; double k; k = POPn; O = POP(_point); A = POP(_point); get_mem(val, _point); val->x = O->x + k*(A->x - O->x); val->y = O->y + k*(A->y - O->y); PSH(val); } void point_abscissa(void) { PSHn((POP(_point))->x); } void point_ordinate(void) { PSHn((POP(_point))->y); } void points_distance(void) { _point *A, *B; A = POP(_point); B = POP(_point); PSHn(distance(A, B)); } eukleides-1.5.4.orig/src/common/setting.h0000644000175000017500000000460511365502244020564 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef __euktopst__ #define HATCHSEP 4 #else #define HATCHSEP .15 #endif #define DEFAULT_DIST .3 extern double min_x, min_y, max_x, max_y, scale; void set_box(_param p); void set_scale(void); void set_global_color(_param p); void set_local_color(_param p); extern int global_color; extern int local_color; void set_global_size(_param p); void set_local_size(_param p); extern double global_size; extern double local_size; void set_global_step(void); void set_local_step(void); extern double global_step; extern double local_step; void set_global_style(_param p); void set_local_style(_param p); extern int global_style; extern int local_style; void set_global_shape(_param p); void set_local_shape(_param p); extern int global_shape; extern int local_shape; void set_global_part(_param p); void set_local_part(_param p); extern int local_part; void set_global_dir(_param p); void set_local_dir(_param p); extern int local_dir; void set_global_arrow(_param p); void set_local_arrow(_param p); extern int local_arrow; void set_global_font(void); void set_local_font(void); extern char *global_font_desc; extern char *local_font_desc; extern int global_font; extern int local_font; void set_global_segment(_param p); void set_local_segment(_param p); extern int local_segment; void set_global_angle(_param p); void set_local_angle(_param p); extern int local_angle; void set_global_dec(_param p); void set_local_dec(_param p); extern int local_dec; extern int global_settings; extern int local_settings; void restore_default_settings(void); void clear_local_settings(void); eukleides-1.5.4.orig/src/common/intersection.h0000644000175000017500000000212011365502244021603 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void orthogonal_projection(void); void parallel_projection(void); void lines_intersection(void); void line_set_intersection(void); void line_circle_intersection(void); void line_conic_intersection(void); void sets_intersection(void); void circles_intersection(void); void circle_set_intersection(void); eukleides-1.5.4.orig/src/common/interactive.h0000644000175000017500000000156511365502244021426 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ extern int strokes[26][2]; void store_mobile(_param p); void store_interactive(_param p); eukleides-1.5.4.orig/src/common/io.c0000644000175000017500000001007611365502244017510 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #ifndef __win__ #include #endif #include "error.h" #include "args.h" #include "core.h" #include "symbol.h" #include "compiler.h" #include "strings.h" #include "utils.h" int output; FILE *data_file; FILE *result_file; FILE *handle(void) { switch (output) { case 0: if (output_file) return output_file; case 1: if (result_file) return result_file; case 2: return stderr; } return stdout; } void open_read_mode(void) { if (data_file && data_file != stdin) fclose(data_file); data_file = fopen(POPs, "r"); if (data_file == NULL) runtime_error("Unable to read data file"); } void open_write_mode(void) { if (result_file) fclose(result_file); result_file = fopen(POPs, "w"); if (result_file == NULL) runtime_error("Unable to write result file"); } void open_append_mode(void) { if (result_file) fclose(result_file); result_file = fopen(POPs, "a"); if (result_file == NULL) runtime_error("Unable to append result file"); } void close_data_file(void) { if (data_file && data_file != stdin) fclose(data_file); else print_warning("No data file to close"); data_file = stdin; } void close_result_file(void) { if (result_file) fclose(result_file); else print_warning("No result file to release"); result_file = NULL; } void print_num(void) { double x; x = POPn; if (ZERO(x)) x = 0.; fprintf(handle(), "%g", x); } void print_pnt(void) { _point *A; A = POP(_point); #ifdef __euktopst__ fprintf(handle(), "(%.4f,%.4f)", A->x, A->y); #else fprintf(handle(), "%7.4f %7.4f", A->x, A->y); #endif } void print_set(void) { _set *s; s = POP(_set); #ifndef __euktopst__ if (s != NULL) { fprintf(handle(), "%7.4f %7.4f", s->p->x, s->p->y); s = s->next; } #endif while (s != NULL) { #ifdef __euktopst__ fprintf(handle(), "(%.4f,%.4f)", s->p->x, s->p->y); #else fprintf(handle(), " %7.4f %7.4f", s->p->x, s->p->y); #endif s = s->next; } } void print_str(void) { fprintf(handle(), "%s", POPs); } void print_nl(void) { fputc('\n', handle()); } void check_data_file(void) { if (!data_file) data_file = stdin; if (opt_batchmode && data_name && data_file == stdin) { data_file = fopen(data_name, "r"); if (data_file == NULL) runtime_error("Unable to read data file"); } } #ifdef __win__ char* readline(char* msg) { char c; printf(msg); start_buffer(); while ((c = getchar()) && c != EOF && c != '\n' && c != '\r') add_char(c); return get_buffer(); } #endif void input_num(void) { double x; check_data_file(); if (data_file == stdin) { if (opt_batchmode) { print_warning("Undefined data in batchmode. Using null value"); PSHn(0.); } else PSHn(atof(readline(POPs))); } else { fscanf(data_file, "%lf", &x); PSHn(x); } } void input_str(void) { char* s = NULL; char c; check_data_file(); start_buffer(); if (data_file == stdin) { if (opt_batchmode) print_warning("Undefined data in batchmode. Using empty string"); else { s = readline(POPs); add_string(s, strlen(s)); } } else while ((c = getc(data_file)) && c != EOF && c != '\n' && c != '\r') add_char(c); PSH(get_buffer()); if (s) free(s); } eukleides-1.5.4.orig/src/common/utils.c0000644000175000017500000000370711365502244020244 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "symbol.h" #include "error.h" #include "utils.h" double Sin(double x) { return sin(DTOR(x)); } double Cos(double x) { return cos(DTOR(x)); } double Tan(double x) { return tan(DTOR(x)); } double Asin(double x) { return RTOD(asin(x)); } double Acos(double x) { return RTOD(acos(x)); } double Atan(double x) { return RTOD(atan(x)); } double det2(double a, double b, double c, double d) { return a*d - b*c; } double det3(double a, double b, double c, double d, double e, double f, double g, double h, double i) { return a*det2(e, f, h, i) - d*det2(b, c, h, i) + g*det2(b, c, e, f); } double Clamp(double x, double y, double z) { return x > z ? z : x < y ? y : x; } double distance(_point *A, _point *B) { return hypot(B->x-A->x, B->y-A->y); } double argument(_point *A, _point *B) { return RTOD(atan2(B->y-A->y, B->x-A->x)); } double principal(double x) { return x - 360*ceil(x/360-.5); } _point *get_point(_set **set) { _point *val; if (*set == NULL) runtime_error(_("invalid set")); val = (*set)->p; (*set) = (*set)->next; return val; } eukleides-1.5.4.orig/src/common/circle.c0000644000175000017500000001142311365502244020337 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" void create_circle_with_radius(void) { _point *center; _circle *val; get_mem(val, _circle); val->r = POPn; if (val->r <= 0) runtime_error("invalid radius"); center = POP(_point); val->x = center->x; val->y = center->y; PSH(val); } void circle_center(void) { _circle *cir; _point *val; cir = POP(_circle); get_mem(val, _point); val->x = cir->x; val->y = cir->y; PSH(val); } void create_circle_with_diameter(void) { _set *set; _point *A, *B; _circle *val; set = POP(_set); A = get_point(&set); B = get_point(&set); get_mem(val, _circle); val->r = distance(A, B)/2; if (val->r <= 0) runtime_error("invalid radius"); val->x = (A->x + B->x)/2; val->y = (A->y + B->y)/2; PSH(val); } void create_circumcircle(void) { _point *A, *B, *C; double a, d, e, f, s1, s2, s3; _circle *val; C = POP(_point); B = POP(_point); A = POP(_point); get_mem(val, _circle); s1 = A->x*A->x + A->y*A->y; s2 = B->x*B->x + B->y*B->y; s3 = C->x*C->x + C->y*C->y; a = det3(A->x, B->x, C->x, A->y, B->y, C->y, 1, 1, 1); if (ZERO(a)) runtime_error("invalid points"); d = det3(s1, s2, s3, A->y, B->y, C->y, 1, 1, 1); e = det3(s1, s2, s3, A->x, B->x, C->x, 1, 1, 1); f = det3(s1, s2, s3, A->x, B->x, C->x, A->y, B->y, C->y); val->r = sqrt((d*d+e*e)/(4*a*a)+f/a); val->x = d/(2*a); val->y = -e/(2*a); PSH(val); } void create_incircle(void) { _point *A, *B, *C; double a, b, c, s, s1, s2, r, t, u, v; _circle *val; C = POP(_point); B = POP(_point); A = POP(_point); get_mem(val, _circle); a = distance(B, C); b = distance(C, A); c = distance(A, B); s = det2(B->x-A->x, C->x-A->x, B->y-A->y, C->y-A->y) > 0 ? 1 : -1; s1 = sqrt((a-b+c)*(a+b-c)); s2 = sqrt((b+c-a)*(b+c+a)); if (ZERO(s1) || ZERO(s2)) runtime_error("invalid points"); r = .5*s1*s2/(a+b+c); t = s1/s2; u = (B->x-A->x)/c; v = (B->y-A->y)/c; val->r = r; val->x = A->x + r*(u/t-s*v); val->y = A->y + r*(v/t+s*u); PSH(val); } void translate_circle(void) { _circle *C, *val; _vector *u; u = POP(_vector); C = POP(_circle); get_mem(val, _circle); val->x = C->x + u->x; val->y = C->y + u->y; val->r = C->r; PSH(val); } void reflect_circle(void) { _circle *C, *val; _line *l; double c, s, x, y, p; l = POP(_line); C = POP(_circle); c = Cos(l->a); s = Sin(l->a); x = C->x - l->x; y = C->y - l->y; p = 2*(c*x + s*y); get_mem(val, _circle); val->x = l->x + p*c - x; val->y = l->y + p*s - y; val->r = C->r; PSH(val); } void symetric_circle(void) { _circle *C, *val; _point *O; O = POP(_point); C = POP(_circle); get_mem(val, _circle); val->x = 2*O->x - C->x; val->y = 2*O->y - C->y; val->r = C->r; PSH(val); } void rotate_circle(void) { _circle *C, *val; _point *O; double a, c, s, x, y; a = POPn; O = POP(_point); C = POP(_circle); c = Cos(a); s = Sin(a); x = C->x - O->x; y = C->y - O->y; get_mem(val, _circle); val->x = O->x + c*x - s*y; val->y = O->y + s*x + c*y; val->r = C->r; PSH(val); } void homothetic_circle(void) { _circle *C, *val; _point *O; double k; k = POPn; O = POP(_point); C = POP(_circle); get_mem(val, _circle); val->x = O->x + k*(C->x - O->x); val->y = O->y + k*(C->y - O->y); val->r = fabs(k)*C->r; PSH(val); } void circle_radius(void) { PSHn((POP(_circle))->r); } void circle_perimeter(void) { PSHn(2*M_PI*(POP(_circle))->r); } void circle_area(void) { _circle *cir; cir = POP(_circle); PSHn(M_PI*cir->r*cir->r); } void point_on_circle_argument(void) { _point *A; _circle *cir; cir = POP(_circle); A = POP(_point); PSHn(RTOD(atan2(A->y-cir->y, A->x-cir->x))); } eukleides-1.5.4.orig/src/common/number.c0000644000175000017500000000610211365502244020364 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" void add(void) { PSHn(POPn + POPn); } void substract(void) { double arg; arg = POPn; PSHn(POPn - arg); } void multiply(void) { PSHn(POPn * POPn); } void divide(void) { double arg; arg = POPn; if (arg == 0) runtime_error(_("division by zero")); PSHn(POPn / arg); } void modulo(void) { double x, y; y = POPn; x = POPn; if (y == 0) runtime_error(_("division by zero")); PSHn(x - floor(x/y)*y); } void change_sign(void) { PSHn(-POPn); } void square_root(void) { double arg; arg = POPn; if (arg < 0) runtime_error(_("invalid argument in sqrt")); PSHn(sqrt(arg)); } void power(void) { double x, y; x = POPn; y = POPn; if (y<0 && x != ceil(x)) runtime_error(_("invalid exponent")); PSHn(pow(y,x)); } void exponential(void) { PSHn(exp(POPn)); } void logarithm(void) { double arg; arg = POPn; if (arg <= 0) runtime_error(_("invalid argument in ln")); PSHn(log(POPn)); } void rtod(void) { PSHn(RTOD(POPn)); } void dtor(void) { PSHn(DTOR(POPn)); } void sine(void) { PSHn(Sin(POPn)); } void cosine(void) { PSHn(Cos(POPn)); } void tangent(void) { double arg; arg = POPn; if (Cos(arg) == 0) runtime_error(_("invalid argument in tan")); PSHn(Tan(arg)); } void arcsine(void) { double arg; arg = POPn; if (arg<-1 || arg>1) runtime_error(_("invalid argument in asin")); PSHn(Asin(arg)); } void arccosine(void) { double arg; arg = POPn; if (arg<-1 || arg>1) runtime_error(_("invalid argument in acos")); PSHn(Acos(arg)); } void arctangent(void) { PSHn(Atan(POPn)); } void absolute_value(void) { PSHn(fabs(POPn)); } void sign(void) { double arg; arg = POPn; PSHn(arg == 0 ? 0. : arg > 0 ? 1. : -1.); } void ceil_value(void) { PSHn(ceil(POPn)); } void floor_value(void) { PSHn(floor(POPn)); } void round_value(void) { PSHn(rint(POPn)); } void minimum(void) { double x, y; x = POPn; y = POPn; PSHn(x < y ? x : y); } void maximum(void) { double x, y; x = POPn; y = POPn; PSHn(x > y ? x : y); } void clamp(void) { double x, y, z; z = POPn; y = POPn; x = POPn; PSHn(Clamp(x, y, z)); } eukleides-1.5.4.orig/src/common/compiler.h0000644000175000017500000000344011365502244020715 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef __debug__ void add_instr(const char* inst, int arg, void (*f)(), _param p); #define instruction(arg, fct, param) add_instr(#fct, arg, fct, param) #else void add_instr(void (*f)(), _param p); #define instruction(arg, fct, param) add_instr(fct, param) #endif int get_addr(void); void store_mark(void); int pop_mark(void); void back_patch(void); void set_type(_symbol *symbol, int type); void lift_type(_symbol *symbol, int type); #define PSH_(arg) instruction(2, push_param, (_param)(arg)) #define INC(ptr) instruction(1, increment, (_param)(void *)ptr) #define GTO(addr) instruction(3, goto_addr, (_param)(addr)) #define GSB(addr) instruction(3, gosub_addr, (_param)(addr)) #define JPZ(addr) instruction(3, jump_if_zero, (_param)(addr)) #define RTN instruction(0, go_back, (_param)NULL) #define STP instruction(0, stop, (_param)NULL) #define XEQ_(fct) instruction(0, fct, (_param)NULL) #define XEQ(fct,ptr) instruction(1, fct, (_param)(void *)ptr) #define SET_(fct,lbl) instruction(3, fct, (_param)(lbl)) eukleides-1.5.4.orig/src/common/triangle.c0000644000175000017500000001074611365502244020712 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" #define STO(addr) (POP(_symbol))->content->value.point = (addr) _point *A, *B, *C; double a, x, y; void assign_A_B(int p) { switch(p) { case 0: get_mem(A, _point); A->x = 0; A->y = 0; STO(A); get_mem(B, _point); B->x = a*x; B->y = a*y; STO(B); break; case 1: A = POP(_point); get_mem(B, _point); B->x = A->x + a*x; B->y = A->y + a*y; STO(B); break; case 2: A = POP(_point); B = POP(_point); a = distance(A, B); if (ZERO(a)) runtime_error(_("invalid points")); x = (B->x - A->x)/a; y = (B->y - A->y)/a; } } void assign_C(double u, double v) { get_mem(C, _point); C->x = A->x + u*x - v*y; C->y = A->y + v*x + u*y; STO(C); } void define_optimal_scalene(_param p) { double t; if (p.addr < 2) { t = POPn; a = POPn; x = Cos(t); y = Sin(t); } assign_A_B(p.addr); assign_C(a*.375, a*.61237244); } void define_triangle_SSS(_param p) { double t, b, c, s1, s2, s, u, v; if (p.addr < 2) { t = POPn; c = POPn; b = POPn; a = POPn; x = Cos(t); y = Sin(t); } else { c = POPn; b = POPn; } assign_A_B(p.addr); s1 = (b-a+c)*(b+a-c); s2 = (a+c-b)*(a+b+c); if (ZERO(s2)) { u = -c; v = 0; } else { s = s1/s2; if (s < 0) runtime_error(_("invalid lengths")); t = 2 * atan(sqrt(s)); u = c*cos(t); v = c*sin(t); } assign_C(u, v); } void define_triangle_SAA(_param p) { double t, c, u, v, cu, su, cv, sv, d; if (p.addr < 2) { t = POPn; v = POPn; u = POPn; a = POPn; x = Cos(t); y = Sin(t); } else { v = POPn; u = POPn; } cu = Cos(u); su = Sin(u); cv = Cos(v); sv = Sin(v); d = cu*sv + su*cv; if (ZERO(d)) runtime_error(_("invalid angles")); assign_A_B(p.addr); c = a*sv/d; assign_C(c*cu, c*su); } void define_triangle_SAS(_param p) { double t, c, u; if (p.addr < 2) { t = POPn; c = POPn; u = POPn; a = POPn; x = Cos(t); y = Sin(t); } else { c = POPn; u = POPn; } assign_A_B(p.addr); assign_C(c*Cos(u), c*Sin(u)); } void define_triangle_SSA(_param p) { double t, b, c, v, cv, sv, s; if (p.addr < 2) { t = POPn; v = POPn; c = POPn; a = POPn; x = Cos(t); y = Sin(t); } else { v = POPn; c = POPn; } assign_A_B(p.addr); cv = Cos(v); sv = Sin(v); s = c*c - a*a*sv*sv; if (s < 0) runtime_error(_("invalid parameters")); b = a*cv + sqrt(s); assign_C(a-b*cv, b*sv); } void define_right_SS(_param p) { double t, b; if (p.addr < 2) { t = POPn; b = POPn; a = POPn; x = Cos(t); y = Sin(t); } else b = POPn; assign_A_B(p.addr); assign_C(a, b); } void define_right_SA(_param p) { double t, u; if (p.addr < 2) { t = POPn; u = POPn; a = POPn; x = Cos(t); y = Sin(t); } else u = POPn; if (u>=90 || u<=-90) runtime_error(_("invalid angle")); assign_A_B(p.addr); assign_C(a, a*Tan(u)); } void define_isoceles_SS(_param p) { double t, b, s; if (p.addr < 2) { t = POPn; b = POPn; a = POPn; x = Cos(t); y = Sin(t); } else b = POPn; assign_A_B(p.addr); a /= 2; s = b*b - a*a; if (s < 0) runtime_error(_("invalid lengths")); assign_C(a, sqrt(s)); } void define_isoceles_SA(_param p) { double t, u; if (p.addr < 2) { t = POPn; u = POPn; a = POPn; x = Cos(t); y = Sin(t); } else u = POPn; if (u>=90 || u<=-90) runtime_error(_("invalid angle")); assign_A_B(p.addr); a /= 2; assign_C(a, a*Tan(u)); } void define_equilateral(_param p) { double t; if (p.addr < 2) { t = POPn; a = POPn; x = Cos(t); y = Sin(t); } assign_A_B(p.addr); a /= 2; assign_C(a, a*sqrt(3)); } eukleides-1.5.4.orig/src/common/io.h0000644000175000017500000000213711365502244017514 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ extern int output; void open_read_mode(void); void open_write_mode(void); void open_append_mode(void); void close_data_file(void); void close_result_file(void); void print_num(void); void print_pnt(void); void print_set(void); void print_str(void); void print_nl(void); void input_num(void); void input_str(void); eukleides-1.5.4.orig/src/common/test.c0000644000175000017500000002050111365502244020052 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" #include "parser.tab.h" void not(void) { PSHn(!pop_param().addr); } void and(void) { int a, b; a = pop_param().addr; b = pop_param().addr; PSHn(a && b); } void or(void) { int a, b; a = pop_param().addr; b = pop_param().addr; PSHn(a || b); } void ternary(void) { double x, y; int z; x = POPn; y = POPn; z = pop_param().addr; PSHn(z ? y : x); } void num_eq(void) { PSHn(EQL(POPn, POPn)); } void num_neq(void) { PSHn(NEQL(POPn, POPn)); } void num_lt(void) { PSHn(POPn > POPn); } void num_leq(void) { PSHn(POPn >= POPn); } void num_gt(void) { PSHn(POPn < POPn); } void num_geq(void) { PSHn(POPn <= POPn); } void pnt_eq(void) { _point *A, *B; B = POP(_point); A = POP(_point); PSHn(EQL(A->x, B->x) && EQL(A->y, B->y)); } void pnt_neq(void) { _point *A, *B; B = POP(_point); A = POP(_point); PSHn(NEQL(A->x, B->x) || NEQL(A->y, B->y)); } void collinear_points(void) { _point *A, *B, *C; C = POP(_point); B = POP(_point); A = POP(_point); PSHn(ZERO(det2(B->x-A->x, B->y-A->y, C->x-A->x, C->y-A->y))); } void vec_eq(void) { _vector *u, *v; v = POP(_vector); u = POP(_vector); PSHn(EQL(u->x, v->x) && EQL(u->y, v->y)); } void vec_neq(void) { _vector *u, *v; v = POP(_vector); u = POP(_vector); PSHn(NEQL(u->x, v->x) || NEQL(u->y, v->y)); } void collinear_vectors(void) { _vector *u, *v; v = POP(_vector); u = POP(_vector); PSHn(ZERO(det2(u->x, u->y, v->x, v->y))); } int elem_eq(_set *s1, _set *s2) { if (s1 == NULL && s2 == NULL) return 1; if (s1 == NULL || s2 == NULL) return 0; if (NEQL(s1->p->x, s2->p->x) || NEQL(s1->p->y, s2->p->y)) return 0; return elem_eq(s1->next, s2->next); } void set_eq(void) { _set *s1, *s2; s2 = POP(_set); s1 = POP(_set); PSHn(elem_eq(s1, s2)); } void set_neq(void) { _set *s1, *s2; s2 = POP(_set); s1 = POP(_set); PSHn(!elem_eq(s1, s2)); } void is_empty(void) { PSHn(POP(_set) == NULL); } int elem_on_path(_point *A, double x, double y, _set *s) { double u, v; if (s->next == NULL) return 0; s = s->next; u = s->p->x-A->x; v = s->p->y-A->y; if (ZERO(det2(x, y, u, v)) && u*x+v*y <= 0) return 1; return elem_on_path(A, u, v, s); } void on_path(void) { _set *s; _point *A; s = POP(_set); A = POP(_point); if (s == NULL) PSHn(0); else if (s->next == NULL) PSHn(EQL(A->x, s->p->x) && EQL(A->y, s->p->y)); else PSHn(elem_on_path(A, s->p->x-A->x, s->p->y-A->y, s)); } int elem_in_set(_point *A, _set *s) { if (s == NULL) return 0; if (EQL(A->x, s->p->x) && EQL(A->y, s->p->y)) return 1; return elem_in_set(A, s->next); } void in_set(void) { _set *s; _point *A; s = POP(_set); A = POP(_point); PSHn(elem_in_set(A, s)); } void lin_eq(void) { _line *l1, *l2; double u, v; l2 = POP(_line); l1 = POP(_line); u = l2->x - l1->x; v = l2->y - l1->y; PSHn(ZERO(det2(u, v, Cos(l1->a), Sin(l1->a))) && ZERO(det2(u, v, Cos(l2->a), Sin(l2->a)))); } void lin_neq(void) { _line *l1, *l2; double u, v; l2 = POP(_line); l1 = POP(_line); u = l2->x - l1->x; v = l2->y - l1->y; PSHn(NEQL(det2(u, v, Cos(l1->a), Sin(l1->a)), 0) || NEQL(det2(u, v, Cos(l2->a), Sin(l2->a)), 0)); } void on_line(void) { _line *l; _point *A; l = POP(_line); A = POP(_point); PSHn(ZERO(det2(l->x-A->x, l->y-A->y, Cos(l->a), Sin(l->a)))); } double delta(double a, double b, double m) { return fmod(fabs(a - b), m); } void parallel_lines(void) { _line *l1, *l2; l2 = POP(_line); l1 = POP(_line); PSHn(ZERO(delta(l1->a, l2->a, 180))); } void perpendicular_lines(void) { _line *l1, *l2; l2 = POP(_line); l1 = POP(_line); PSHn(EQL(delta(l1->a, l2->a, 180), 90)); } void cir_eq(void) { _circle *c1, *c2; c2 = POP(_circle); c1 = POP(_circle); PSHn(EQL(c1->x, c2->x) && EQL(c1->y, c2->y) && EQL(c1->r, c2->r)); } void cir_neq(void) { _circle *c1, *c2; c2 = POP(_circle); c1 = POP(_circle); PSHn(NEQL(c1->x, c2->x) || NEQL(c1->y, c2->y) || NEQL(c1->r, c2->r)); } void on_circle(void) { _circle *c; _point *A; c = POP(_circle); A = POP(_point); PSHn(EQL(hypot(c->x-A->x, c->y-A->y), c->r)); } void con_eq(void) { _conic *c1, *c2; c2 = POP(_conic); c1 = POP(_conic); PSHn(c1->type == c2->type && EQL(c1->x, c2->x) && EQL(c1->y, c2->y) && EQL(c1->a, c2->a) && EQL(c1->b, c2->b) && ZERO(delta(c1->d, c2->d, c1->type == PARABOLA ? 360 : 180))); } void con_neq(void) { _conic *c1, *c2; c2 = POP(_conic); c1 = POP(_conic); PSHn(c1->type != c2->type || NEQL(c1->x, c2->x) || NEQL(c1->y, c2->y) || NEQL(c1->a, c2->a) || NEQL(c1->b, c2->b) || NEQL(delta(c1->d, c2->d, c1->type == PARABOLA ? 360 : 180), 0)); } void on_conic(void) { _conic *C; _point *A; double c, s, x, y, u, v; C = POP(_conic); A = POP(_point); c = Cos(C->d); s = Sin(C->d); x = A->x - C->x; y = A->y - C->y; u = c*x + s*y; v = -s*x + c*y; switch (C->type) { case ELLIPSE: PSHn(EQL(u*u/(C->a*C->a) + v*v/(C->b*C->b), 1)); break; case HYPERBOLA: PSHn(EQL(u*u/(C->a*C->a) - v*v/(C->b*C->b), 1)); break; case PARABOLA: PSHn(EQL(C->a*(2*u + C->a), v*v)); break; } } void is_ellipse(void) { PSHn((POP(_conic))->type == ELLIPSE); } void is_hyperbola(void) { PSHn((POP(_conic))->type == HYPERBOLA); } void is_parabola(void) { PSHn((POP(_conic))->type == PARABOLA); } void is_isosceles(void) { _point *A, *B, *C; C = POP(_point); B = POP(_point); A = POP(_point); PSHn(EQL(distance(C, A), distance(C, B))); } void is_equilateral(void) { _point *A, *B, *C; double c; C = POP(_point); B = POP(_point); A = POP(_point); c = distance(A, B); PSHn(EQL(c, distance(B, C)) && EQL(c, distance(C, A))); } void is_right(void) { _point *A, *B, *C; double a, b, c; C = POP(_point); B = POP(_point); A = POP(_point); a = distance(B, C); b = distance(C, A); c = distance(A, B); PSHn(EQL(b*b, a*a + c*c)); } void is_parallelogram(void) { _point *A, *B, *C, *D; D = POP(_point); C = POP(_point); B = POP(_point); A = POP(_point); PSHn(EQL(A->x+C->x, B->x+D->x) && EQL(A->y+C->y, B->y+D->y)); } void is_rectangle(void) { _point *A, *B, *C, *D; double a, b; D = POP(_point); C = POP(_point); B = POP(_point); A = POP(_point); a = distance(A, C); b = distance(B, D); PSHn(EQL(A->x+C->x, B->x+D->x) && EQL(A->y+C->y, B->y+D->y) && EQL(a, b)); } void is_square(void) { _point *A, *B, *C, *D; double a, b, c, d; D = POP(_point); C = POP(_point); B = POP(_point); A = POP(_point); a = distance(A, C); b = distance(B, D); c = distance(A, B); d = distance(A, D); PSHn(EQL(A->x+C->x, B->x+D->x) && EQL(A->y+C->y, B->y+D->y) && EQL(a, b) && EQL(c, d)); } void eps_output(void) { #ifdef __eukleides__ PSHn(1); #else PSHn(0); #endif } void pstricks_output(void) { #ifdef __euktopst__ PSHn(1); #else PSHn(0); #endif } void display_output(void) { #ifdef __geukleides__ PSHn(1); #else PSHn(0); #endif } void for_test(void) { double c, s, e; c = POPn; s = POPn; e = POPn; PSHn(s); if ((c > e && s > 0) || (c < e && s < 0)) PSHn(0); else PSHn(1); } eukleides-1.5.4.orig/src/common/module.h0000644000175000017500000000155411365502244020374 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ char *get_module_name(void); int get_lineno(void); void init_module_stack(void); eukleides-1.5.4.orig/src/common/symbol.c0000644000175000017500000000665211365502244020413 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #ifdef MO_DIR #include #else #define gettext(msg) (msg) #endif #include "error.h" #include "symbol.h" #include "core.h" #include "compiler.h" #include "parser.tab.h" /* Symbol list */ typedef struct { _symbol **first; _symbol **last; _symbol **end; } _list; _list list; #define LIST_INIT_SIZE 128 void init_symbol_list(void) { list.first = (_symbol **)malloc(LIST_INIT_SIZE*sizeof(_symbol *)); check_mem(list.first); list.last = list.first; list.end = list.first + LIST_INIT_SIZE; } void resize_symbol_list(void) { int size = list.end - list.first; list.first = (_symbol **)realloc(list.first, 2*size*sizeof(_symbol *)); check_mem(list.first); list.last = list.first + size; list.end = list.first + 2*size; } void push_symbol(_symbol *s) { *(list.last++) = s; if (list.last == list.end) resize_symbol_list(); } _symbol *pop_symbol(void) { if (list.last > list.first) return *(--list.last); return (_symbol *)NULL; } void reset_symbol_list(void) { list.last = list.first; } #define TABLE_SIZE 3001 _symbol *table[TABLE_SIZE]; unsigned int hash(char *ptr) { unsigned int val = 0, tmp; while (*ptr != '\0') { val = (val << 4) + *ptr; tmp = val & 0xf0000000; if (tmp) { val = val ^ tmp >> 24; val = val ^ tmp; } ptr++; } return val % TABLE_SIZE; } _symbol *look_up_symbol(char *symbol, unsigned int index) { _symbol *entry; entry = table[index]; while (entry) { if (strcmp(entry->symbol, symbol) == 0) return entry; entry = entry->next; } return NULL; } _symbol *write_symbol(char *symbol, int type, unsigned int index) { _symbol *entry; entry = (_symbol *)malloc(sizeof(_symbol)); check_mem(entry); entry->symbol = strdup(symbol); entry->index = index; entry->content = (_content *)malloc(sizeof(_content)); check_mem(entry->content); entry->content->type = type; entry->next = table[index]; table[index] = entry; return entry; } void add_symbol(char *symbol, int type) { char *s; s = gettext(symbol); write_symbol(s, type, hash(s)); } _symbol *update_table (char *symbol) { unsigned int index; _symbol *entry; index = hash(symbol); entry = look_up_symbol(symbol, index); if (entry == NULL) { entry = write_symbol(symbol, SYMBOL, index); push_symbol(entry); } return entry; } void clear_entry(_symbol *entry) { table[entry->index] = entry->next; free(entry->symbol); free(entry->content); free(entry); } void clear_table(void) { _symbol *entry; while ((entry = pop_symbol())) clear_entry(entry); } eukleides-1.5.4.orig/src/common/keywords.h0000644000175000017500000000146311365502244020755 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void load_keywords(void); eukleides-1.5.4.orig/src/common/conic.c0000644000175000017500000001671611365502244020203 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" #include "parser.tab.h" void create_ellipse(void) { _point *v; _conic *val; get_mem(val, _conic); val->type = ELLIPSE; val->d = POPn; val->b = POPn; val->a = POPn; if (val->a <= 0 || val->b <= 0 || val->a < val->b) runtime_error("invalid parameters"); v = POP(_point); val->x = v->x; val->y = v->y; PSH(val); } void create_hyperbola(void) { _point *v; _conic *val; get_mem(val, _conic); val->type = HYPERBOLA; val->d = POPn; val->b = POPn; val->a = POPn; if (val->a <= 0 || val->b <= 0) runtime_error("invalid parameters"); v = POP(_point); val->x = v->x; val->y = v->y; PSH(val); } void create_parabola(void) { _point *v; _conic *val; get_mem(val, _conic); val->type = PARABOLA; val->d = POPn; val->b = 0; val->a = POPn; if (val->a <= 0) runtime_error("invalid parameters"); v = POP(_point); val->x = v->x + val->a*Cos(val->d)/2; val->y = v->y + val->a*Sin(val->d)/2; PSH(val); } void conic_center(void) { _conic *c; _point *val; c = POP(_conic); if (c->type == PARABOLA) runtime_error("undefined center"); get_mem(val, _point); val->x = c->x; val->y = c->y; PSH(val); } void conic_foci(void) { _conic *C; _set *first, *second; double c, s, f; C = POP(_conic); if (C->type == PARABOLA) { get_elem(first); first->p->x = C->x; first->p->y = C->y; first->next = NULL; } else { c = Cos(C->d); s = Sin(C->d); f = sqrt(C->a*C->a + C->b*C->b*(C->type == ELLIPSE ? -1 : 1)); get_elem(first); get_elem(second); first->p->x = C->x + c*f; first->p->y = C->y + s*f; first->next = second; second->p->x = C->x - c*f; second->p->y = C->y - s*f; second->next = NULL; } PSH(first); } void create_conic_with_directrix(void) { _point *A; _line *l; _conic *val; double e, c, s, d, f, h; e = POPn; if (e <= 0) runtime_error("invalid eccentricity"); l = POP(_line); A = POP(_point); c = Cos(l->a); s = Sin(l->a); d = s*(A->x-l->x) - c*(A->y-l->y); if (ZERO(d)) runtime_error("invalid parameters"); get_mem(val, _conic); if (e == 1) { val->x = A->x; val->y = A->y; val->a = fabs(d); val->b = 0; val->type = PARABOLA; } else { h = 1/e - e; f = fabs(d)*e/h; val->x = A->x + s*f; val->y = A->y - c*f; val->a = fabs(d/h); if (e < 1) { val->b = val->a*sqrt(1 - e*e); val->type = ELLIPSE; } else { val->b = val->a*sqrt(e*e - 1); val->type = HYPERBOLA; } } val->d = principal(l->a + (d < 0 ? 90 : -90)); PSH(val); } void create_conic_with_foci(void) { _point *A, *B; _conic *val; double a, f; a = POPn; if (a <= 0) runtime_error("invalid major or real axis"); B = POP(_point); A = POP(_point); f = distance(A, B); if (ZERO(f) || EQL(f, a)) runtime_error("invalid parameters"); get_mem(val, _conic); val->x = (A->x + B->x)/2; val->y = (A->y + B->y)/2; val->a = a; val->d = argument(A, B); if (f < a) { val->b = sqrt(a*a - f*f); val->type = ELLIPSE; } else { val->b = sqrt(f*f - a*a); val->type = HYPERBOLA; } PSH(val); } void translate_conic(void) { _conic *C, *val; _vector *u; u = POP(_vector); C = POP(_conic); get_mem(val, _conic); val->x = C->x + u->x; val->y = C->y + u->y; val->a = C->a; val->b = C->b; val->d = C->d; val->type = C->type; PSH(val); } void reflect_conic(void) { _conic *C, *val; _line *l; double c, s, x, y, p; l = POP(_line); C = POP(_conic); c = Cos(l->a); s = Sin(l->a); x = C->x - l->x; y = C->y - l->y; p = 2*(c*x + s*y); get_mem(val, _conic); val->x = l->x + p*c - x; val->y = l->y + p*s - y; val->a = C->a; val->b = C->b; val->d = principal(2*l->a - C->d); val->type = C->type; PSH(val); } void symetric_conic(void) { _conic *C, *val; _point *O; O = POP(_point); C = POP(_conic); get_mem(val, _conic); val->x = 2*O->x - C->x; val->y = 2*O->y - C->y; val->a = C->a; val->b = C->b; val->d = C->d + (C->d > 0 ? -180 : 180); val->type = C->type; PSH(val); } void rotate_conic(void) { _conic *C, *val; _point *O; double a, c, s, x, y; a = POPn; O = POP(_point); C = POP(_conic); c = Cos(a); s = Sin(a); x = C->x - O->x; y = C->y - O->y; get_mem(val, _conic); val->x = O->x + c*x - s*y; val->y = O->y + s*x + c*y; val->a = C->a; val->b = C->b; val->d = principal(C->d + a); val->type = C->type; PSH(val); } void homothetic_conic(void) { _conic *C, *val; _point *O; double k; k = POPn; O = POP(_point); C = POP(_conic); get_mem(val, _conic); val->x = O->x + k*(C->x - O->x); val->y = O->y + k*(C->y - O->y); val->a = fabs(k)*C->a; val->b = fabs(k)*C->b; val->d = C->d; val->type = C->type; PSH(val); } void major_axis(void) { PSHn((POP(_conic))->a); } void minor_axis(void) { PSHn((POP(_conic))->b); } void eccentricity(void) { _conic *C; C = POP(_conic); switch (C->type) { case ELLIPSE: PSHn(sqrt(1 - C->b*C->b/(C->a*C->a))); break; case HYPERBOLA: PSHn(sqrt(1 + C->b*C->b/(C->a*C->a))); break; case PARABOLA: PSHn(1.); break; } } void conic_argument(void) { PSHn((POP(_conic))->d); } void point_on_conic_argument(void) { _conic *C; _point *A; double c, s, x, y, u, v; C = POP(_conic); A = POP(_point); c = Cos(C->d); s = Sin(C->d); x = A->x - C->x; y = A->y - C->y; u = c*x + s*y; v = -s*x + c*y; switch (C->type) { case ELLIPSE: PSHn(RTOD(atan2(v*C->a, u*C->b))); break; case HYPERBOLA: PSHn(RTOD(atan2(C->b, v)) - (u < 0 ? 180 : 0)); break; case PARABOLA: PSHn(RTOD(atan2(-v, (C->a - v*v/C->a)/2))); break; } } void parametric_ellipse(double *x, double *y, double t, double x0, double y0, double a, double b, double c, double s) { double u, v; u = a*Cos(t); v = b*Sin(t); *x = x0 + c*u - s*v; *y = y0 + s*u + c*v; } void parametric_hyperbola(double *x, double *y, double t, double x0, double y0, double a, double b, double c, double s) { double u, v; u = a/Sin(t); v = b/Tan(t); *x = x0 + c*u - s*v; *y = y0 + s*u + c*v; } void parametric_parabola(double *x, double *y, double t, double x0, double y0, double p, double c, double s) { double q, r, u, v; q = Cos(t); r = -p/(1 + q); u = r*q; v = r*Sin(t); *x = x0 + c*u - s*v; *y = y0 + s*u + c*v; } eukleides-1.5.4.orig/src/common/compiler.c0000644000175000017500000000341511365502244020712 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "error.h" #include "core.h" #include "symbol.h" extern _itable itable; #ifdef __debug__ void add_instr(const char* inst, int arg, void (*f)(void), _param p) { itable.last->inst = inst; itable.last->arg = arg; #else void add_instr(void (*f)(void), _param p) { #endif itable.last->func = f; itable.last->param = p; itable.last++; if (itable.last == itable.end) resize_instr_table(); } int get_addr(void) { return itable.last - itable.tbl; } void store_mark() { push_param((_param)get_addr()); } int pop_mark(void) { return pop_param().addr; } void back_patch(void) { _instr *instr; instr = itable.tbl + pop_mark() - 1; instr->param.addr += get_addr(); } void set_type(_symbol *symbol, int type) { symbol->content->type = type; } void lift_type(_symbol *symbol, int type) { _content *content; get_mem(content, _content); content->type = type; content->next = symbol->content; symbol->content = content; } eukleides-1.5.4.orig/src/common/set.h0000644000175000017500000000252711365502244017703 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void create_set(void); void create_segment(void); void add_head_point(void); void add_tail_point(void); void catenate_sets(void); void push_point(void); void extract_point(_param p); void extract_subset(_param p); void create_polygon(void); void translate_set(void); void reflect_set(void); void symetric_set(void); void rotate_set(void); void homothetic_set(void); void set_cardinal(void); void path_length(_param p); void polygon_area(void); void create_centroid(void); void segment_argument(void); void vertex_angle(void); void triangle_height(void); eukleides-1.5.4.orig/src/common/lexer.l0000644000175000017500000001055111365502244020227 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ %option never-interactive noyywrap nounput noinput %{ #include #include "error.h" #include "args.h" #include "strings.h" #include "core.h" #include "interactive.h" #include "symbol.h" #include "parser.tab.h" /* Module stack */ #define MAX_DEPTH 20 struct { YY_BUFFER_STATE buffer[MAX_DEPTH]; char* name[MAX_DEPTH]; int lineno[MAX_DEPTH]; int index; } mstack; void init_module_stack(void) { mstack.index = 0; mstack.name[0] = input_name; mstack.lineno[0] = 1; yyin = fopen(input_name, "r"); if (yyin == NULL) fatal_error(_("Unable to open input file")); } void incr_lineno(void) { mstack.lineno[mstack.index]++; } void load_module(char *name, int len) { mstack.buffer[mstack.index++] = YY_CURRENT_BUFFER; if (mstack.index == MAX_DEPTH) fatal_error(_("Too many levels of inclusion")); yyin = fopen(name, "r"); if (yyin == NULL) fatal_error(_("Unable to open module")); yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); start_buffer(); add_string(name, len); mstack.name[mstack.index] = get_buffer(); mstack.lineno[mstack.index] = 1; } int flush_module(void) { if (mstack.index == 0) return 0; yy_delete_buffer(YY_CURRENT_BUFFER); yy_switch_to_buffer(mstack.buffer[--mstack.index]); return 1; } char *get_module_name(void) { return mstack.name[mstack.index]; } int get_lineno(void) { return mstack.lineno[mstack.index]; } /* Init string */ int processed = 0; void process_init_string(char *s) { char *c; if (processed) return; for (c = s; *c != '\0'; c++) { if (*c >= 'a' && *c <= 'z') strokes[(int)(*c - 'a')][0] = atoi(c+1); if (*c >= 'A' && *c <= 'Z') strokes[(int)(*c - 'A')][1] = atoi(c+1); } processed = 1; } %} %x STR0 %x STR1 n \n|\r|(\r\n) p [^\n\r] w [\t ]+ %% /* Ignore whitespace */ {w} /* Protected line breaks */ \\{n} { incr_lineno(); } /* Comments */ %({p}*){n} { incr_lineno(); return '\n'; } /* Modules */ ^@{p}+ { load_module(yytext+1, yyleng-1); yylval.string = get_module_name(); return MODULE; } <> { if (flush_module()) { yylval.string = get_module_name(); return MODULE; } else yyterminate(); } /* Init string */ ^#{p}*{n} { process_init_string(yytext+1); incr_lineno(); } /* States */ #[A-Z] { yylval.state = (int)(yytext[1]-'A'); return STATE; } /* Numbers */ [0-9]+|[0-9]*\.[0-9]+ { yylval.number = atof(yytext); return CONST_NUM; } /* Strings */ \" { start_buffer(); BEGIN STR0; } [^"%\n\r]* { add_string(yytext, yyleng); } %[nrt"%] { add_special_char(yytext[1]); } \"{n}{w}\" { incr_lineno(); } \" { BEGIN INITIAL; yylval.string = get_buffer(); return CONST_STR; } \$ { start_buffer(); #ifdef __euktopst__ add_char('$'); #endif BEGIN STR1; } [^$%\n\r]* { add_string(yytext, yyleng); } %[nrt$%] { add_special_char(yytext[1]); } \${n}{w}\$ { incr_lineno(); } \$ { BEGIN INITIAL; #ifdef __euktopst__ add_char('$'); #endif yylval.string = get_buffer(); return CONST_STR; } %[0-9]{1,3} { add_char((char)atoi(yytext+1)); } % { yyerror(_("invalid character")); } {n} { yyerror(_("unterminated string")); } /* Symbols */ [A-Z_a-zÀ-ÖØ-öø-ÿ]['0-9A-Z_a-zÀ-ÖØ-öø-ÿ]* { yylval.ptr = update_table(yytext); return yylval.ptr->content->type; } /* Special symbols */ == { return EQ; } != { return NEQ; } "<=" { return LEQ; } ">=" { return GEQ; } ° { return DEG; } /* End of lines */ {n} { incr_lineno(); return '\n'; } /* Anything else */ . { return *yytext; } %% eukleides-1.5.4.orig/src/common/vector.h0000644000175000017500000000244211365502244020406 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; fromout even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along from this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void create_vector_cartesian(void); void create_vector_polar(void); void create_vector_from_points(void); void create_vector_from_segment(void); void create_vector_from_line(void); void add_vectors(void); void substract_vectors(void); void reverse_vector(void); void multiply_vector(void); void divide_vector(void); void rotate_vector(void); void vector_abscissa(void); void vector_ordinate(void); void vector_length(void); void vector_argument(void); void vectors_angle(void); void scalar_product(void); eukleides-1.5.4.orig/src/common/point.h0000644000175000017500000000263111365502244020235 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void create_point_cartesian(void); void create_point_polar(void); void create_point_on_segment(void); void create_point_on_line(void); void create_point_with_abscissa(void); void create_point_with_ordinate(void); void create_point_on_circle(void); void create_point_on_conic(void); void create_midpoint(void); void create_isobarycenter(void); void create_barycenter(void); void create_orthocenter(void); void translate_point(void); void reflect_point(void); void symetric_point(void); void rotate_point(void); void homothetic_point(void); void point_abscissa(void); void point_ordinate(void); void points_distance(void); eukleides-1.5.4.orig/src/common/quadrilateral.c0000644000175000017500000000565711365502244021744 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" #define STO(addr) (POP(_symbol))->content->value.point = (addr) double l, m, x, y, u, v; _point *A, *B, *C, *D; void assign(int p, int s) { if (p < 3) { switch(p) { case 0: get_mem(A, _point); A->x = 0; A->y = 0; STO(A); get_mem(B, _point); B->x = l*x; B->y = l*y; STO(B); break; case 1: A = POP(_point); get_mem(B, _point); B->x = A->x + l*x; B->y = A->y + l*y; STO(B); break; case 2: A = POP(_point); B = POP(_point); l = distance(A, B); if (ZERO(l)) runtime_error(_("invalid points")); x = (B->x - A->x)/l; y = (B->y - A->y)/l; } if (s == 1) m = l; get_mem(C, _point); C->x = B->x + m*(u*x - v*y); C->y = B->y + m*(v*x + u*y); STO(C); } else { A = POP(_point); B = POP(_point); C = POP(_point); } get_mem(D, _point); D->x = A->x + C->x - B->x; D->y = A->y + C->y - B->y; STO(D); } void define_parallelogram_SSA(_param p) { double a, b; if (p.addr < 2) { b = POPn; a = POPn; m = POPn; l = POPn; x = Cos(b); y = Sin(b); u = Cos(a); v = Sin(a); } else if (p.addr == 2) { a = POPn; m = POPn; u = Cos(a); v = Sin(a); } assign(p.addr, 0); } void define_parallelogram_VV(_param p) { _vector *u, *v; v = POP(_vector); u = POP(_vector); if (p.addr == 0) { get_mem(A, _point); A->x = 0; A->y = 0; STO(A); } else A = POP(_point); get_mem(B, _point); B->x = A->x + u->x; B->y = A->y + u->y; STO(B); get_mem(C, _point); C->x = A->x + u->x + v->x; C->y = A->y + u->y + v->y; STO(C); get_mem(D, _point); D->x = A->x + v->x; D->y = A->y + v->y; STO(D); } void define_rectangle(_param p) { double b; if (p.addr < 2) { b = POPn; m = POPn; l = POPn; x = Cos(b); y = Sin(b); } else m = POPn; u = 0; v = 1; assign(p.addr, 0); } void define_square(_param p) { double b; if (p.addr < 2) { b = POPn; l = POPn; x = Cos(b); y = Sin(b); } u = 0; v = 1; assign(p.addr, 1); } eukleides-1.5.4.orig/src/common/args.h0000644000175000017500000000221711365502244020040 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void process_args(int argc, char *argv[]); extern char *input_name; #ifndef __geukleides__ extern FILE *output_file; extern char *output_name; extern int opt_ouput; extern int opt_batchmode; extern char *data_name; #ifdef __eukleides__ extern int anim_state; extern int anim_dir; extern int anim_amount; extern int anim_cur; extern int anim_inc; #endif #endif eukleides-1.5.4.orig/src/common/error.c0000644000175000017500000000310711365502244020227 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #ifdef MO_DIR #include #else #define gettext(msg) (msg) #endif #include "args.h" #include "module.h" #include "error.h" void fatal_error(char* msg) { fprintf(stderr, "%s.\n", gettext(msg)); exit(EXIT_FAILURE); } void yyerror(char *msg) { fprintf(stderr, "%s:%d: %s.\n", get_module_name(), get_lineno(), gettext(msg)); exit(EXIT_FAILURE); } extern int cur_line; extern char* cur_file; void runtime_error(char* msg) { #ifndef __win__ close(1); #endif fprintf(stderr, "%s:%d: %s.\n", cur_file, cur_line, gettext(msg)); exit(EXIT_FAILURE); } void check_ptr(void *ptr) { if (ptr == NULL) fatal_error(_("Memory overflow")); } void print_warning(char* msg) { fprintf(stderr, "%s.\n", gettext(msg)); } eukleides-1.5.4.orig/src/common/locus.c0000644000175000017500000000274611365502244020233 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "error.h" #include "symbol.h" #include "core.h" int locus_addr = 0, num; double start, step; _symbol *variable; void init_locus(_param p) { double end; num = (int)POPn; if (num <= 0) runtime_error(_("illegal step number")); end = POPn; start = POPn; variable = (_symbol *)p.ptr; variable->content->value.number = end; step = (end-start)/num; PSH(NULL); PSHn(1); } void put_pnt(void) { _set *head, *tail; _point *cur; cur = POP(_point); tail = POP(_set); get_mem(head, _set); head->p = cur; head->next = tail; PSH(head); num--; variable->content->value.number = start + num*step; PSHn(num >= 0); } eukleides-1.5.4.orig/src/common/interactive.c0000644000175000017500000000435511365502244021421 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" int strokes[26][2]; void store_mobile(_param p) { double step, min_x = 0, min_y = 0, max_x = 0, max_y = 0, x, y; int mode, i; _point *O, *val; char *c; O = POP(_point); mode = pop_param().addr; if (mode >= 4) { max_y = POPn; max_x = POPn; min_y = POPn; min_x = POPn; } if (mode % 2 == 1) step = POPn; else step = .1; if (mode % 4 < 2) { c = ((_symbol *)p.ptr)->symbol; if (*c < 'A' || *c > 'Z' || c[1] != '\0') runtime_error(_("invalid state")); i = (int)(*c - 'A'); } else i = pop_param().addr; x = O->x + step*strokes[i][0]; y = O->y + step*strokes[i][1]; if (mode >= 4) { if (min_x > max_x || min_y > max_y) runtime_error(_("invalid boundaries")); x = Clamp(x, min_x, max_x); y = Clamp(y, min_y, max_y); } get_mem(val, _point); val->x = x; val->y = y; ((_symbol *)p.ptr)->content->value.point = val; } void store_interactive(_param p) { double n, step = 0.1, min = 0, max = 0; int dir, i, mode; dir = pop_param().addr; n = POPn; mode = pop_param().addr; switch (mode) { case 3: step = POPn; case 2: max = POPn; min = POPn; if (min > max) runtime_error(_("invalid boundaries")); break; case 1: step = POPn; } i = pop_param().addr; n += step*strokes[i][dir]; if (mode > 1) n = Clamp(n, min, max); ((_symbol *)p.ptr)->content->value.number = n; } eukleides-1.5.4.orig/src/common/intersection.c0000644000175000017500000002044611365502244021611 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "conic.h" #include "utils.h" #include "parser.tab.h" void orthogonal_projection(void) { _point *A, *val; _line *l; double c, s, p; l = POP(_line); A = POP(_point); c = Cos(l->a); s = Sin(l->a); p = c*(A->x - l->x) + s*(A->y - l->y); get_mem(val, _point); val->x = l->x + p*c; val->y = l->y + p*s; PSH(val); } void push_intersection_point(double x1, double y1, double a1, double x2, double y2, double a2) { double c1, c2, s1, s2, d, b1, b2; _point *val; c1 = Cos(a1); s1 = Sin(a1); c2 = Cos(a2); s2 = Sin(a2); d = det2(c1, c2, s1, s2); if (ZERO(d)) runtime_error(_("parallel lines")); b1 = det2(x1, y1, c1, s1); b2 = det2(x2, y2, c2, s2); get_mem(val, _point); val->x = det2(c1, c2, b1, b2)/d; val->y = det2(s1, s2, b1, b2)/d; PSH(val); } void parallel_projection(void) { _line *l1, *l2; _point *A; l2 = POP(_line); l1 = POP(_line); A = POP(_point); push_intersection_point(l1->x, l1->y, l1->a, A->x, A->y, l2->a); } void lines_intersection(void) { _line *l1, *l2; l2 = POP(_line); l1 = POP(_line); push_intersection_point(l1->x, l1->y, l1->a, l2->x, l2->y, l2->a); } #define dist(s) a*(s)->p->x+b*(s)->p->y+c _set *line_segment_intersection(_set *s, double a, double b, double c, double d) { _set *val, *t; double e, f, g; t = s->next; if (t == NULL) return NULL; e = dist(t); if (d*e <= EPSILON && fabs(e) > EPSILON) { get_elem(val); f = fabs(d) + fabs(e); g = f == 0 ? 0 : fabs(d)/f; val->p->x = s->p->x + g*(t->p->x-s->p->x); val->p->y = s->p->y + g*(t->p->y-s->p->y); val->next = line_segment_intersection(t, a, b, c, e); return val; } return line_segment_intersection(t, a, b, c, e); } void line_set_intersection(void) { _line *l; _set *s; double a, b, c; s = POP(_set); l = POP(_line); if (s == NULL) { PSH(NULL); return; } a = Sin(l->a); b = -Cos(l->a); c = -a*l->x-b*l->y; PSH(line_segment_intersection(s, a, b, c, dist(s))); } int solve(double *x1, double *x2, double a, double b, double c) { double d, r; if (ZERO(a)) { if (ZERO(b)) return 0; *x1 = *x2 = -c/b; return 1; } d = b*b - 4*a*c; if (d < 0) return 0; if (ZERO(d)) { *x1 = *x2 = -b/(2*a); return 1; } r = sqrt(d); *x1 = (-b - r)/(2*a); *x2 = (-b + r)/(2*a); return 2; } void line_circle_intersection(void) { _line *l; _circle *C; _set *first = NULL, *second = NULL; double c, s, x, y, t1, t2; int n = 0; C = POP(_circle); l = POP(_line); x = l->x - C->x; y = l->y - C->y; c = Cos(l->a); s = Sin(l->a); n = solve(&t1, &t2, 1, 2*(x*c + y*s), x*x + y*y - C->r*C->r); if (n > 0) { get_elem(first); first->p->x = l->x + c*t1; first->p->y = l->y + s*t1; if (n > 1) { get_elem(second); second->p->x = l->x + c*t2; second->p->y = l->y + s*t2; second->next = NULL; } first->next = second; } PSH(first); } void line_conic_intersection(void) { _line *l; _conic *C; _set *first = NULL, *second = NULL; double c, s, a, b, x, y, ca, sa, u, v, t1, t2; int n = 0; C = POP(_conic); l = POP(_line); c = Cos(C->d); s = Sin(C->d); a = C->a*C->a; b = C->b*C->b; x = c*(l->x - C->x) + s*(l->y - C->y); y = -s*(l->x - C->x) + c*(l->y - C->y); ca = Cos(l->a); sa = Sin(l->a); u = c*ca + s*sa; v = -s*ca + c*sa; switch (C->type) { case ELLIPSE: n = solve(&t1, &t2, u*u/a + v*v/b, 2*(x*u/a + y*v/b), x*x/a + y*y/b - 1); break; case HYPERBOLA: n = solve(&t1, &t2, u*u/a - v*v/b, 2*(x*u/a - y*v/b), x*x/a - y*y/b - 1); break; case PARABOLA: n = solve(&t1, &t2, v*v/(2*C->a), y*v/C->a - u, y*y/(2*C->a) - x - C->a/2); break; } if (n > 0) { get_elem(first); first->p->x = l->x + ca*t1; first->p->y = l->y + sa*t1; if (n > 1) { get_elem(second); second->p->x = l->x + ca*t2; second->p->y = l->y + sa*t2; second->next = NULL; } first->next = second; } PSH(first); } #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) void sets_intersection(void) { _set *s, *t, *u, *v, *w, *a = NULL, *b; double d1, d2, c1, c2, s1, s2, x, y, d, t1, t2; u = POP(_set); s = POP(_set); if (u == NULL || s == NULL) { PSH(NULL); return; } t = s->next; while (t) { v = u; w = u->next; while (w) { if (max(s->p->x, t->p->x) >= min(v->p->x, w->p->x) && max(v->p->x, w->p->x) >= min(s->p->x, t->p->x) && max(s->p->y, t->p->y) >= min(v->p->y, w->p->y) && max(v->p->y, w->p->y) >= min(s->p->y, t->p->y)) { d1 = distance(s->p, t->p); c1 = (t->p->x - s->p->x)/d1; s1 = (t->p->y - s->p->y)/d1; d2 = distance(v->p, w->p); c2 = (w->p->x - v->p->x)/d2; s2 = (w->p->y - v->p->y)/d2; x = v->p->x - s->p->x; y = v->p->y - s->p->y; d = det2(c1, c2, s1, s2); if (ZERO(d)) { if (ZERO(det2(x, y, c1, s1))) { b = a; get_mem(a, _set); a->p = s->p; a->next = b; } } else { t1 = det2(x, y, c2, s2)/d; t2 = det2(x, y, c1, s1)/d; if (t1 >= 0 && t1 <= d1 && t2 >= 0 && t2 <= d2) { b = a; get_elem(a); a->p->x = s->p->x + c1*t1; a->p->y = s->p->y + s1*t1; a->next = b; } } } v = w; w = w->next; } s = t; t = t->next; } PSH(a); } void circles_intersection(void) { _circle *c1, *c2; _set *first, *second; double x, y, a, b, c, t, u, v; c2 = POP(_circle); c1 = POP(_circle); x = c2->x-c1->x; y = c2->y-c1->y; a = hypot(x, y); b = c2->r; c = c1->r; if (ZERO(a) || a > b+c || a < fabs(b-c)) { PSH(NULL); return; } x /= a; y /= a; if (a == b+c || a == fabs(b-c)) { get_elem(first); first->p->x = c1->x + c*x; first->p->y = c1->y + c*y; first->next = NULL; PSH(first); return; } get_elem(first); get_elem(second); t = 2 * atan(sqrt((b-a+c)*(b+a-c)/((a+c-b)*(a+b+c)))); u = c*cos(t); v = c*sin(t); first->p->x = c1->x + u*x - v*y; first->p->y = c1->y + v*x + u*y; first->next = second; second->p->x = c1->x + u*x + v*y; second->p->y = c1->y - v*x + u*y; second->next = NULL; PSH(first); } #undef dist #define dist(s) hypot((s)->p->x - c->x, (s)->p->y - c->y) _set *circle_segment_intersection(_set *s, _circle* c, double d) { _set *v1 = NULL, *v2 = NULL, *t; double e, f, x, y, u, v, t1, t2; int n; t = s->next; if (t == NULL) return NULL; e = dist(t); if (d >= c->r || e >= c->r) { f = distance(s->p, t->p); x = s->p->x - c->x; y = s->p->y - c->y; u = (t->p->x - s->p->x)/f; v = (t->p->y - s->p->y)/f; n = solve(&t1, &t2, 1, 2*(x*u + y*v), x*x + y*y - c->r*c->r); if (n > 0) { if (n > 1 && t2 >= 0 && t2 <= f) { get_elem(v2); v2->p->x = s->p->x + u*t2; v2->p->y = s->p->y + v*t2; v2->next = circle_segment_intersection(t, c, e); } if (t1 >= 0 && t1 <= f) { get_elem(v1); v1->p->x = s->p->x + u*t1; v1->p->y = s->p->y + v*t1; if (v2) v1->next = v2; else v1->next = circle_segment_intersection(t, c, e); } if (v1) return v1; if (v2) return v2; } } return circle_segment_intersection(t, c, e); } void circle_set_intersection(void) { _circle *c; _set *s; s = POP(_set); c = POP(_circle); if (s == NULL) { PSH(NULL); return; } PSH(circle_segment_intersection(s, c, dist(s))); } eukleides-1.5.4.orig/src/common/conic.h0000644000175000017500000000317611365502244020204 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void create_ellipse(void); void create_hyperbola(void); void create_parabola(void); void conic_center(void); void conic_foci(void); void create_conic_with_directrix(void); void create_conic_with_foci(void); void translate_conic(void); void reflect_conic(void); void symetric_conic(void); void rotate_conic(void); void homothetic_conic(void); void major_axis(void); void minor_axis(void); void eccentricity(void); void conic_argument(void); void point_on_conic_argument(void); void parametric_ellipse(double *x, double *y, double t, double x0, double y0, double a, double b, double c, double s); void parametric_hyperbola(double *x, double *y, double t, double x0, double y0, double a, double b, double c, double s); void parametric_parabola(double *x, double *y, double t, double x0, double y0, double p, double c, double s); eukleides-1.5.4.orig/src/common/core.c0000644000175000017500000001344611365502244020035 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "core.h" #include "symbol.h" /* Parameter stack */ typedef struct { _param *stk; _param *last; _param *end; } _pstack; _pstack pstack; #define PSTACK_INIT_SIZE 1024 void init_param_stack(void) { pstack.stk = (_param *)malloc(PSTACK_INIT_SIZE * sizeof(_param)); check_mem(pstack.stk); pstack.last = pstack.stk; pstack.end = pstack.stk + PSTACK_INIT_SIZE; } void resize_param_stack(void) { int size = pstack.end - pstack.stk; pstack.stk = (_param *)realloc(pstack.stk, 2 * size * sizeof(_param)); check_mem(pstack.stk); pstack.last = pstack.stk + size; pstack.end = pstack.stk + 2 * size; } void push_param(_param p) { *(pstack.last++) = p; if (pstack.last == pstack.end) resize_param_stack(); } _param pop_param(void) { if (pstack.last > pstack.stk) return *(--pstack.last); runtime_error(_("empty parameter stack")); return (_param)0; } void reset_param_stack(void) { pstack.last = pstack.stk; } /* Return address stack */ typedef struct { _instr **stk; _instr **last; _instr **end; } _rstack; _rstack rstack; #define RSTACK_INIT_SIZE 1024 void init_return_stack(void) { rstack.stk = (_instr **)malloc(RSTACK_INIT_SIZE * sizeof(_instr *)); check_mem(rstack.stk); rstack.last = rstack.stk; rstack.end = rstack.stk + RSTACK_INIT_SIZE; } void resize_return_stack(void) { int size = rstack.end - rstack.stk; rstack.stk = (_instr **)realloc(rstack.stk, 2 * size * sizeof(_instr *)); check_mem(rstack.stk); rstack.last = rstack.stk + size; rstack.end = rstack.stk + 2 * size; } void push_addr(_instr *a) { *(rstack.last++) = a; if (rstack.last == rstack.end) resize_return_stack(); } _instr *pop_addr(void) { if (rstack.last > rstack.stk) return *(--rstack.last); runtime_error(_("empty return stack")); return (_instr *)NULL; } void reset_return_stack(void) { rstack.last = rstack.stk; } /* Instruction table */ _itable itable; #define ITABLE_INIT_SIZE 16384 void init_instr_table(void) { itable.tbl = (_instr *)malloc(ITABLE_INIT_SIZE * sizeof(_instr)); check_mem(itable.tbl); itable.last = itable.tbl; itable.end = itable.tbl + ITABLE_INIT_SIZE; } void resize_instr_table(void) { int size = itable.end - itable.tbl; itable.tbl = (_instr *)realloc(itable.tbl, 2 * size * sizeof(_instr)); check_mem(itable.tbl); itable.last = itable.tbl + size; itable.end = itable.tbl + 2 * size; } void goto_addr(_param p) { itable.cur = itable.tbl + p.addr - 1; } void gosub_addr(_param p) { push_addr(itable.cur); itable.cur = itable.tbl + p.addr - 1; } void go_back(void) { itable.cur = pop_addr(); } void jump_if_zero(_param p) { if (pop_param().addr == 0) itable.cur = itable.tbl + p.addr - 1; } void stop(void) { itable.cur = itable.last; } int cur_line; void set_cur_line(_param p) { cur_line = p.addr; } char* cur_file; void set_cur_file(_param p) { cur_file = (char *)p.ptr; } #ifdef __debug__ void echo_itable(void) { static int i = 0; _instr* ins; if (i) return; for (ins = itable.tbl; ins < itable.last; ins++, i++) switch(ins->arg) { case 0: fprintf(stderr, "%04d %-12s\n", i, ins->inst); break; case 1: fprintf(stderr, "%04d %-12s %p\n", i, ins->inst, ins->param.ptr); break; case 2: fprintf(stderr, "%04d %-12s %g\n", i, ins->inst, ins->param.num); break; case 3: fprintf(stderr, "%04d %-12s %04d\n", i, ins->inst, ins->param.addr); } } #endif void exec_itable(void) { #ifdef __debug__ echo_itable(); #endif for (itable.cur = itable.tbl; itable.cur < itable.last; itable.cur++) (itable.cur->func)(itable.cur->param); } void reset_instr_table(void) { itable.last = itable.tbl; } /* Memory pages */ typedef struct { void **start; void **cur; void *first; void *last; } _mpages; _mpages mem; #define PAGE_SIZE (16384 - sizeof(void *)) void init_memory(void) { mem.first = malloc(PAGE_SIZE); check_ptr(mem.first); mem.start = mem.cur = (void **)mem.first; *mem.cur = NULL; mem.last = mem.first + sizeof(void *); } void *allocate(int size) { void *addr; if (mem.last-mem.first+size > PAGE_SIZE) { if (size > PAGE_SIZE) runtime_error(_("memory allocation error")); if (*mem.cur == NULL) { mem.first = malloc(PAGE_SIZE); check_ptr(mem.first); *mem.cur = mem.first; mem.cur = (void **)mem.first; *mem.cur = NULL; } else mem.first = *mem.cur; mem.last = mem.first + sizeof(void *); } addr = mem.last; mem.last += size; return addr; } void reset_memory(void) { mem.cur = mem.start; mem.first = (void *)mem.start; mem.last = mem.first + sizeof(void *); } /* Stack machine */ void init_stack_machine(void) { init_param_stack(); init_return_stack(); init_instr_table(); init_memory(); } void reset_stack_machine(void) { reset_param_stack(); reset_return_stack(); reset_instr_table(); reset_memory(); } eukleides-1.5.4.orig/src/common/quadrilateral.h0000644000175000017500000000165411365502244021742 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void define_parallelogram_SSA(_param p); void define_parallelogram_VV(_param p); void define_rectangle(_param p); void define_square(_param p); eukleides-1.5.4.orig/src/common/variable.h0000644000175000017500000000311111365502244020663 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void recall_num(_param p); void recall_pnt(_param p); void recall_vec(_param p); void recall_set(_param p); void recall_lin(_param p); void recall_cir(_param p); void recall_con(_param p); void recall_str(_param p); void store_num(_param p); void store_pnt(_param p); void store_vec(_param p); void store_set(_param p); void multiple_store(_param p); void store_at_index(_param p); void store_at_end(_param p); void store_lin(_param p); void store_cir(_param p); void store_con(_param p); void store_str(_param p); void increment(_param p); void lift_num(_param p); void lift_pnt(_param p); void lift_vec(_param p); void lift_set(_param p); void lift_lin(_param p); void lift_cir(_param p); void lift_con(_param p); void lift_str(_param p); void lift_sym(_param p); void drop(_param p); eukleides-1.5.4.orig/src/common/variable.c0000644000175000017500000001270011365502244020662 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "parser.tab.h" void recall_num(_param p) { PSHn(((_symbol *)p.ptr)->content->value.number); } #define recall(var, type) \ push_param((_param)(void *)(((_symbol *)var.ptr)->content->value.type)) void recall_pnt(_param p) { recall(p, point); } void recall_vec(_param p) { recall(p, vector); } void recall_lin(_param p) { recall(p, line); } void recall_cir(_param p) { recall(p, circle); } void recall_con(_param p) { recall(p, conic); } void recall_str(_param p) { recall(p, string); } _set *copy_set(_set *set) { _set *copy; if (set == NULL) return NULL; get_mem(copy, _set); copy->p = set->p; copy->next = copy_set(set->next); return copy; } void recall_set(_param p) { PSH(copy_set(((_symbol *)p.ptr)->content->value.set)); } void store_num(_param p) { ((_symbol *)p.ptr)->content->value.number = POPn; } void store_pnt(_param p) { ((_symbol *)p.ptr)->content->value.point = POP(_point); } void store_vec(_param p) { ((_symbol *)p.ptr)->content->value.vector = POP(_vector); } void store_set(_param p) { ((_symbol *)p.ptr)->content->value.set = POP(_set); } void multiple_store(_param p) { _set *set; _symbol *cur; set = POP(_set); cur = POP(_symbol); while (cur != NULL) { if (set == NULL) runtime_error(_("invalid set")); cur->content->value.point = set->p; set = set->next; cur = POP(_symbol); } } void store_at_index(_param p) { _set *cur; _point *A; double i; cur = ((_symbol *)p.ptr)->content->value.set; A = POP(_point); i = POPn; while (i >= 1 && cur != NULL) { i--; cur = cur->next; } if (i < 0 || cur == NULL) runtime_error(_("index out of range")); cur->p = A; } void store_at_end(_param p) { _set *cur, *end; _point *A; cur = ((_symbol *)p.ptr)->content->value.set; A = POP(_point); get_mem(end, _set); if (cur == NULL) ((_symbol *)p.ptr)->content->value.set = end; else { while (cur->next != NULL) cur = cur->next; cur->next = end; } end->p = A; end->next = NULL; } void store_lin(_param p) { ((_symbol *)p.ptr)->content->value.line = POP(_line); } void store_cir(_param p) { ((_symbol *)p.ptr)->content->value.circle = POP(_circle); } void store_con(_param p) { ((_symbol *)p.ptr)->content->value.conic = POP(_conic); } void store_str(_param p) { ((_symbol *)p.ptr)->content->value.string = POPs; } void increment(_param p) { ((_symbol *)p.ptr)->content->value.number += POPn; //push_param((_param)((_symbol *)p.ptr)->content->value.number); } void lift_num(_param p) { _content *content; get_mem(content, _content); content->value.number = POPn; content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void lift_pnt(_param p) { _content *content; get_mem(content, _content); content->value.point = POP(_point); content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void lift_vec(_param p) { _content *content; get_mem(content, _content); content->value.vector = POP(_vector); content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void lift_set(_param p) { _content *content; get_mem(content, _content); content->value.set = POP(_set); content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void lift_lin(_param p) { _content *content; get_mem(content, _content); content->value.line = POP(_line); content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void lift_cir(_param p) { _content *content; get_mem(content, _content); content->value.circle = POP(_circle); content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void lift_con(_param p) { _content *content; get_mem(content, _content); content->value.conic = POP(_conic); content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void lift_str(_param p) { _content *content; get_mem(content, _content); content->value.string = POPs; content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void lift_sym(_param p) { _content *content; get_mem(content, _content); content->type = SYMBOL; content->next = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content; } void drop(_param p) { _content *content; content = ((_symbol *)p.ptr)->content; ((_symbol *)p.ptr)->content = content->next; } eukleides-1.5.4.orig/src/common/test.h0000644000175000017500000000343011365502244020061 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void not(void); void and(void); void or(void); void ternary(void); void num_eq(void); void num_neq(void); void num_lt(void); void num_leq(void); void num_gt(void); void num_geq(void); void pnt_eq(void); void pnt_neq(void); void collinear_points(void); void vec_eq(void); void vec_neq(void); void collinear_vectors(void); void set_eq(void); void set_neq(void); void is_empty(void); void on_path(void); void in_set(void); void lin_eq(void); void lin_neq(void); void on_line(void); void parallel_lines(void); void perpendicular_lines(void); void cir_eq(void); void cir_neq(void); void on_circle(void); void con_eq(void); void con_neq(void); void on_conic(void); void is_ellipse(void); void is_hyperbola(void); void is_parabola(void); void is_isosceles(void); void is_equilateral(void); void is_right(void); void is_parallelogram(void); void is_rectangle(void); void is_square(void); void eps_output(void); void pstricks_output(void); void display_output(void); void for_test(void); eukleides-1.5.4.orig/src/common/line.h0000644000175000017500000000301211365502244020025 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void create_line_with_argument(void); void create_line_with_points(void); void create_line_with_vector(void); void create_line_with_segment(void); void create_tangent_to_circle(void); void create_tangent_to_conic(void); void create_parallel_to_line(void); void create_parallel_to_segment(void); void create_perpendicular_to_line(void); void create_perpendicular_to_segment(void); void create_perpendicular_bisector(void); void create_angle_bisector(void); void create_lines_bisector(void); void create_altitude(void); void create_median(void); void translate_line(void); void reflect_line(void); void symetric_line(void); void rotate_line(void); void homothetic_line(void); void point_line_distance(void); void line_argument(void); eukleides-1.5.4.orig/src/common/strings.h0000644000175000017500000000233111365502244020572 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void init_string(void); void start_buffer(void); void add_string(char *s, int l); void add_char(char ch); void add_special_char(char ch); char *get_buffer(void); void extract_substring(void); void start_string(void); void cat_num(void); void cat_pnt(void); void cat_set(void); void cat_str(void); void get_string(void); void str_eq(void); void str_neq(void); void str_length(void); char* get_output_name(char* in, const char* suf); eukleides-1.5.4.orig/src/common/line.c0000644000175000017500000002053011365502244020024 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "conic.h" #include "utils.h" #include "parser.tab.h" void create_line_with_argument(void) { _point *O; _line *val; get_mem(val, _line); val->a = POPn; O = POP(_point); val->x = O->x; val->y = O->y; PSH(val); } void create_line_with_points(void) { _point *A, *B; _line *val; B = POP(_point); A = POP(_point); if (EQL(A->x, B->x) && EQL(A->y, B->y)) runtime_error(_("undefined line")); get_mem(val, _line); val->x = A->x; val->y = A->y; val->a = argument(A, B); PSH(val); } void create_line_with_vector(void) { _point *O; _vector *u; _line *val; get_mem(val, _line); u = POP(_vector); O = POP(_point); val->x = O->x; val->y = O->y; val->a = RTOD(atan2(u->y, u->x)); PSH(val); } void create_line_with_segment(void) { _set *seg; _point *A, *B; _line *val; seg = POP(_set); A = get_point(&seg); B = get_point(&seg); if (EQL(A->x, B->x) && EQL(A->y, B->y)) runtime_error(_("undefined line")); get_mem(val, _line); val->x = A->x; val->y = A->y; val->a = argument(A, B); PSH(val); } void create_tangent_to_circle(void) { double a; _circle *c; _line *val; a = POPn; c = POP(_circle); get_mem(val, _line); val->x = c->x + c->r*Cos(a); val->y = c->y + c->r*Sin(a); val->a = a + (a<=90 ? 90 : -270); PSH(val); } void create_tangent_to_conic(void) { double c, s, t, a = 0; _conic *C; _line *val; t = POPn; C = POP(_conic); c = Cos(C->d); s = Sin(C->d); get_mem(val, _line); switch (C->type) { case ELLIPSE: parametric_ellipse(&(val->x), &(val->y), t, C->x, C->y, C->a, C->b, c, s); a = atan2(C->b*Cos(t), -C->a*Sin(t)); break; case HYPERBOLA: if (t <= -180 || t > 180) runtime_error("invalid argument"); if (t == 0 || t == 180) { val->x = C->x; val->y = C->y; a = atan2(C->b, C->a*(t == 0 ? 1 : -1)); } else { parametric_hyperbola(&(val->x), &(val->y), t, C->x, C->y, C->a, C->b, c, s); a = atan2(-C->b, -C->a*Cos(t)); } break; case PARABOLA: if (t <= -180 || t >= 180) runtime_error("invalid argument"); parametric_parabola(&(val->x), &(val->y), t, C->x, C->y, C->a, c, s); a = atan2(-1 - Cos(t), Sin(t)); break; } val->a = principal(RTOD(a) + C->d); PSH(val); } void create_parallel_to_line(void) { _point *O; _line *l, *val; O = POP(_point); l = POP(_line); get_mem(val, _line); val->x = O->x; val->y = O->y; val->a = l->a; PSH(val); } void create_parallel_to_segment(void) { _set *seg; _point *O, *A, *B; _line *val; O = POP(_point); seg = POP(_set); A = get_point(&seg); B = get_point(&seg); if (EQL(A->x, B->x) && EQL(A->y, B->y)) runtime_error(_("invalid segment")); get_mem(val, _line); val->x = O->x; val->y = O->y; val->a = argument(A, B); PSH(val); } void create_perpendicular_to_line(void) { _point *O; _line *l, *val; O = POP(_point); l = POP(_line); get_mem(val, _line); val->x = O->x; val->y = O->y; val->a = l->a + (l->a<=90 ? 90 : -270); PSH(val); } void create_perpendicular_to_segment(void) { _set *seg; _point *O, *A, *B; double a; _line *val; O = POP(_point); seg = POP(_set); A = get_point(&seg); B = get_point(&seg); if (EQL(A->x, B->x) && EQL(A->y, B->y)) runtime_error(_("invalid segment")); a = argument(A, B); get_mem(val, _line); val->x = O->x; val->y = O->y; val->a = a + (a<=90 ? 90 : -270); PSH(val); } void create_perpendicular_bisector(void) { _set *set; _point *A, *B; double a; _line *val; set = POP(_set); A = get_point(&set); B = get_point(&set); if (EQL(A->x, B->x) && EQL(A->y, B->y)) runtime_error(_("invalid set")); get_mem(val, _line); a = argument(A, B); val->x = (A->x + B->x)/2; val->y = (A->y + B->y)/2; val->a = a + (a<=90 ? 90 : -270); PSH(val); } void create_angle_bisector(void) { _point *A, *B, *C; _line *val; C = POP(_point); B = POP(_point); A = POP(_point); if ((EQL(A->x, B->x) && EQL(A->y, B->y)) || (EQL(B->x, C->x) && EQL(B->y, C->y))) runtime_error(_("invalid angle")); get_mem(val, _line); val->x = B->x; val->y = B->y; val->a = (argument(B, A) + argument(B, C))/2; PSH(val); } void create_lines_bisector(void) { double c1, c2, s1, s2, d, b1, b2, a; _line *l1, *l2, *val = NULL; l1 = POP(_line); l2 = POP(_line); c1 = Cos(l1->a); s1 = Sin(l1->a); c2 = Cos(l2->a); s2 = Sin(l2->a); d = det2(c1, c2, s1, s2); if (ZERO(d)) if (ZERO(det2(l2->x-l1->x, l2->y-l1->y, c1, s1))) val = l1; else runtime_error(_("parallel lines")); else { get_mem(val, _line); b1 = det2(l1->x, l1->y, c1, s1); b2 = det2(l2->x, l2->y, c2, s2); val->x = det2(c1, c2, b1, b2)/d; val->y = det2(s1, s2, b1, b2)/d; a = (l1->a + l2->a)/2; if (fabs(l1->a - l2->a)>90) a += (a<=90 ? 90 : -270); val->a = a; } PSH(val); } void create_altitude(void) { _point *A, *B, *C; double a; _line *val; C = POP(_point); B = POP(_point); A = POP(_point); a = argument(B, C); get_mem(val, _line); val->x = A->x; val->y = A->y; val->a = a + (a<=90 ? 90 : -270); PSH(val); } void create_median(void) { _point *A, *B, *C; double x, y; _line *val; C = POP(_point); B = POP(_point); A = POP(_point); x = (B->x + C->x)/2; y = (B->y + C->y)/2; if (EQL(A->x, x) && EQL(A->y, y)) runtime_error(_("invalid triangle")); get_mem(val, _line); val->x = A->x; val->y = A->y; val->a = RTOD(atan2(y-A->y, x-A->x)); PSH(val); } void translate_line(void) { _line *l, *val; _vector *u; u = POP(_vector); l = POP(_line); get_mem(val, _line); val->x = l->x + u->x; val->y = l->y + u->y; val->a = l->a; PSH(val); } void reflect_line(void) { _line *l, *d, *val; double c, s, x, y, p; d = POP(_line); l = POP(_line); c = Cos(l->a); s = Sin(l->a); x = l->x - d->x; y = l->y - d->y; p = 2*(c*x + s*y); get_mem(val, _line); val->x = d->x + p*c - x; val->y = d->y + p*s - y; val->a = principal(2*d->a - l->a); PSH(val); } void symetric_line(void) { _point *O; _line *l, *val; O = POP(_point); l = POP(_line); get_mem(val, _line); val->x = 2*O->x - l->x; val->y = 2*O->y - l->y; val->a = l->a + (l->a > 0 ? -180 : 180); PSH(val); } void rotate_line(void) { _point *O; _line *l, *val; double a, c, s, x, y; a = POPn; O = POP(_point); l = POP(_line); c = Cos(a); s = Sin(a); x = l->x - O->x; y = l->y - O->y; get_mem(val, _line); val->x = O->x + c*x - s*y; val->y = O->y + s*x + c*y; val->a = principal(l->a + a); PSH(val); } void homothetic_line(void) { _point *O; _line *l, *val; double k; k = POPn; O = POP(_point); l = POP(_line); if (k == 0) runtime_error(_("invalid ratio")); get_mem(val, _line); val->x = O->x + k*(l->x - O->x); val->y = O->y + k*(l->y - O->y); val->a = l->a + (k < 0 ? (l->a > 0 ? -180 : 180) : 0); PSH(val); } void point_line_distance(void) { _line *l; _point *A; double c, s; l = POP(_line); A = POP(_point); c = Cos(l->a); s = Sin(l->a); PSHn(fabs(s*(A->x-l->x) - c*(A->y-l->y))); } void line_argument(void) { PSHn((POP(_line))->a); } eukleides-1.5.4.orig/src/common/locus.h0000644000175000017500000000154111365502244020230 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ extern int locus_addr; void init_locus(_param p); void put_pnt(void); eukleides-1.5.4.orig/src/common/set.c0000644000175000017500000001707411365502244017701 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" void create_set(void) { _set *set; _point *pnt; get_mem(set, _set); pnt = POP(_point); set->p = pnt; set->next = NULL; PSH(set); } void create_segment(void) { _set *first, *second; _point *tmp; get_mem(second, _set); tmp = POP(_point); second->p = tmp; second->next = NULL; get_mem(first, _set); tmp = POP(_point); first->p = tmp; first->next = second; PSH(first); } void add_head_point(void) { _set *head, *tail; tail = POP(_set); get_mem(head, _set); head->p = POP(_point); head->next = tail; PSH(head); } void add_tail_point(void) { _set *head, *cur, *tail; get_mem(tail, _set); tail->p = POP(_point); tail->next = NULL; head = POP(_set); if (head == NULL) head = tail; else { for (cur = head; cur->next != NULL; cur = cur->next); cur->next = tail; } PSH(head); } void catenate_sets(void) { _set *first, *second, *cur; second = POP(_set); first = POP(_set); if (first == NULL) first = second; else { for (cur = first; cur->next != NULL; cur = cur->next); cur->next = second; } PSH(first); } void push_point(void) { _set *s; s = POP(_set); if (s == NULL) PSH(0); else { PSH(s->next); PSH(s->p); PSH(1); } } void extract_point(_param p) { double ind; _set *s; _point *val; ind = POPn; if (p.ptr) s = ((_symbol *)p.ptr)->content->value.set; else s = POP(_set); if (ind < 0) runtime_error(_("index out of range")); while (ind-- >= 1 && s != NULL) s = s->next; if (s == NULL) runtime_error(_("index out of range")); get_mem(val, _point); val->x = s->p->x; val->y = s->p->y; PSH(val); } void extract_subset(_param p) { double i, j, k; _set *cur, *val; j = POPn; i = POPn; cur = POP(_set); if (i < 0 || j < i) runtime_error(_("invalid indices")); k = i; while (k-- >= 1 && cur != NULL) cur = cur->next; if (cur == NULL) runtime_error(_("first index out of range")); val = cur; k = j - i; while (k-- >= 1 && cur != NULL) cur = cur->next; if (cur == NULL) runtime_error(_("second index out of range")); cur->next = NULL; PSH(val); } _set *set_vertex(double x, double y, _point* O, double S, double C, double n) { _set *val; if (n < 1) return NULL; get_elem(val); val->p->x = O->x + x; val->p->y = O->y + y; val->next = set_vertex(C*x-S*y, S*x+C*y, O, S, C, n-1); return val; } void create_polygon(void) { _point *O; double n, r, a; a = POPn; r = POPn; O = POP(_point); n = POPn; if (n < 2) runtime_error(_("invalid vertices number")); PSH(set_vertex(r*Cos(a), r*Sin(a), O, sin(2*M_PI/n), cos(2*M_PI/n), n)); } void translate_set(void) { _set *s, *first; _point *cur; _vector *u; u = POP(_vector); first = s = POP(_set); while (s != NULL) { get_mem(cur, _point); cur->x = s->p->x + u->x; cur->y = s->p->y + u->y; s->p = cur; s = s->next; } PSH(first); } void reflect_set(void) { _set *s, *first; _line *l; _point *cur; double C, S, x, y, p; l = POP(_line); first = s = POP(_set); C = Cos(l->a); S = Sin(l->a); while (s != NULL) { get_mem(cur, _point); x = s->p->x - l->x; y = s->p->y - l->y; p = 2*(C*x + S*y); cur->x = l->x + p*C - x; cur->y = l->y + p*S - y; s->p = cur; s = s->next; } PSH(first); } void symetric_set(void) { _set *s, *first; _point *O, *cur; O = POP(_point); first = s = POP(_set); while (s != NULL) { get_mem(cur, _point); cur->x = 2*O->x - s->p->x; cur->y = 2*O->y - s->p->y; s->p = cur; s = s->next; } PSH(first); } void rotate_set(void) { _set *s, *first; _point *O, *cur; double a, C, S, x, y; a = POPn; O = POP(_point); first = s = POP(_set); C = Cos(a); S = Sin(a); while (s != NULL) { get_mem(cur, _point); x = s->p->x - O->x; y = s->p->y - O->y; cur->x = O->x + C*x - S*y; cur->y = O->y + S*x + C*y; s->p = cur; s = s->next; } PSH(first); } void homothetic_set(void) { _set *s, *first; _point *O, *cur; double k; k = POPn; O = POP(_point); first = s = POP(_set); while (s != NULL) { get_mem(cur, _point); cur->x = O->x + k*(s->p->x - O->x); cur->y = O->y + k*(s->p->y - O->y); s->p = cur; s = s->next; } PSH(first); } void set_cardinal(void) { double c = 0; _set *cur; cur = POP(_set); if (cur != NULL) { c = 1; while (cur->next != NULL) { c++; cur = cur->next; } } PSHn(c); } void path_length(_param p) { double l = 0; _set *cur, *first; first = cur = POP(_set); if (cur != NULL) { while (cur->next != NULL) { l += distance(cur->p, cur->next->p); cur = cur->next; } if (p.addr) l += distance(cur->p, first->p); } PSHn(l); } double compute_area(_set *A, _set* B) { if (B->next == NULL) return B->p->x*A->p->y - A->p->x*B->p->y; else return B->p->x*B->next->p->y - B->next->p->x*B->p->y + compute_area(A, B->next); } void polygon_area(void) { _set *A; A = POP(_set); if (A == NULL) PSHn(0); else PSHn(fabs(compute_area(A, A))*.5); } void compute_centroid(_set *A, _set *B, _point *C) { double d; if (B->next == NULL) { d = B->p->x*A->p->y - A->p->x*B->p->y; C->x += (B->p->x + A->p->x)*d; C->y += (B->p->y + A->p->y)*d; } else { d = B->p->x*B->next->p->y - B->next->p->x*B->p->y; C->x += (B->p->x + B->next->p->x)*d; C->y += (B->p->y + B->next->p->y)*d; compute_centroid(A, B->next, C); } } void create_centroid(void) { _set *A; _point *C; double a; A = POP(_set); if (A == NULL) runtime_error(_("empty set")); get_mem(C, _point); if (A->next == NULL) { C->x = A->p->x; C->y = A->p->y; } else { compute_centroid(A, A, C); a = 6.*fabs(compute_area(A, A))*.5; C->x /= a; C->y /= a; } PSH(C); } void segment_argument(void) { _set *seg; _point *A, *B; seg = POP(_set); A = get_point(&seg); B = get_point(&seg); PSHn(argument(A, B)); } void vertex_angle(void) { _point *A, *B, *C; double a, b, c; C = POP(_point); B = POP(_point); A = POP(_point); a = distance(B, C); b = distance(C, A); c = distance(A, B); if (ZERO(a) || ZERO(c)) runtime_error(_("invalid angle")); PSHn(Acos((a*a + c*c - b*b)/(2*a*c))); } void triangle_height(void) { _point *A, *B, *C; double a, b, c, k; C = POP(_point); B = POP(_point); A = POP(_point); a = distance(B, C); b = distance(C, A); c = distance(A, B); if (ZERO(a)) runtime_error(_("invalid triangle")); k = (a + b + c)/2; PSHn(2*sqrt(k*(k-a)*(k-b)*(k-c))/a); } eukleides-1.5.4.orig/src/common/strings.c0000644000175000017500000001265211365502244020574 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "core.h" #include "symbol.h" #include "utils.h" #include "error.h" /* String table */ typedef struct { char **first; char **last; char **mark; char **end; } _strtab; _strtab tab; #define STRTAB_INIT_SIZE 64 void init_string_table(void) { tab.first = (char **)malloc(STRTAB_INIT_SIZE * sizeof(char *)); check_mem(tab.first); tab.last = tab.first; tab.end = tab.first + STRTAB_INIT_SIZE; } void resize_string_table(void) { int size = tab.end - tab.first; tab.first = (char **)realloc(tab.first, 2 * size * sizeof(char *)); check_mem(tab.first); tab.last = tab.first + size; tab.end = tab.first + 2 * size; } void register_string(char *s) { *(tab.last++) = s; if (tab.last == tab.end) resize_string_table(); } void reset_string_table(void) { tab.last = tab.first; } /* String buffer stack */ typedef struct { char *buf; char *cur; int size; } _strbuf; typedef struct { _strbuf *first; _strbuf *last; _strbuf *end; } _bufstk; _bufstk stk; #define STRSTK_INIT_SIZE 64 void init_buffer_stack(void) { stk.first = (_strbuf *)malloc(STRSTK_INIT_SIZE*sizeof(_strbuf)); check_mem(stk.first); stk.last = stk.first - 1; stk.end = stk.first + STRSTK_INIT_SIZE; } void resize_buffer_stack(void) { int size = stk.end - stk.first; stk.first = (_strbuf *)realloc(stk.first, 2*size*sizeof(_strbuf)); check_mem(stk.first); stk.last = stk.first + size; stk.end = stk.first + 2*size; } void init_string(void) { init_string_table(); init_buffer_stack(); } /* String buffer */ #define BUF_INIT_SIZE 128 void start_buffer(void) { stk.last++; stk.last->buf = (char *)malloc(BUF_INIT_SIZE); check_mem(stk.last->buf); stk.last->cur = stk.last->buf; stk.last->size = BUF_INIT_SIZE; if (stk.last == stk.end) resize_buffer_stack(); } void resize_buffer(int amount) { int pos, size; pos = stk.last->cur - stk.last->buf; size = stk.last->size + amount; while (stk.last->size < size) stk.last->size *= 2; stk.last->buf = (char *)realloc(stk.last->buf, stk.last->size); check_mem(stk.last->buf); stk.last->cur = stk.last->buf + pos; } void add_string(char *s, int l) { if (stk.last->cur - stk.last->buf + l > stk.last->size) resize_buffer(l); memcpy((void*)stk.last->cur, (void *)s, l); stk.last->cur += l; } void add_char(char c) { if (stk.last->cur - stk.last->buf == stk.last->size) resize_buffer(1); *(stk.last->cur++) = c; } char get_special_char(char c) { switch (c) { case 'n': return '\n'; case 'r': return '\r'; case 't': return '\t'; } return c; } void add_special_char(char c) { add_char(get_special_char(c)); } char *get_buffer(void) { char *val; add_char('\0'); val = (char *)realloc(stk.last->buf, stk.last->size); register_string(val); stk.last--; return val; } /* String functions */ void extract_substring(void) { char *s; double a, b; int i, j; b = POPn; a = POPn; s = POPs; i = (int)a; j = (int)b; if (a < 0 || b < a || j >= strlen(s)) runtime_error(_("invalid indices")); start_buffer(); add_string(s + i, j - i + 1); PSH(get_buffer()); } void start_string(void) { start_buffer(); } char tmp[31]; void cat_num(void) { double x; x = POPn; add_string(tmp, snprintf(tmp, 14, "%g", fabs(x) < EPSILON ? 0 : x)); } void cat_pnt(void) { _point *A; A = POP(_point); #ifdef __euktopst__ add_string(tmp, snprintf(tmp, 31, "(%.4f, %.4f)", A->x, A->y)); #else add_string(tmp, snprintf(tmp, 28, "%7.4f %7.4f", A->x, A->y)); #endif } void cat_set(void) { _set *s; s = POP(_set); #ifndef __euktopst__ if (s != NULL) { add_string(tmp, snprintf(tmp, 28, "%7.4f %7.4f", s->p->x, s->p->y)); s = s->next; } #endif while (s != NULL) { #ifdef __euktopst__ add_string(tmp, snprintf(tmp, 31, "(%.4f, %.4f)", s->p->x, s->p->y)); #else add_string(tmp, snprintf(tmp, 29, " %7.4f %7.4f", s->p->x, s->p->y)); #endif s = s->next; } } void cat_str(void) { char *s; s = POPs; add_string(s, strlen(s)); } void get_string(void) { PSH(get_buffer()); } void str_eq(void) { PSHn(strcmp(POPs, POPs) == 0); } void str_neq(void) { PSHn(strcmp(POPs, POPs) != 0); } void str_length(void) { PSHn((double)strlen(POPs)); } char* get_output_name(char* in, const char* suf) { int l; char* out; l = strlen(in); if (l >= 4 && strcmp(in + l - 4, ".euk") == 0) l -= 4; out = (char *)malloc(l + 5); strncpy(out, in, l); strncpy(out + l, suf, 5); return out; } eukleides-1.5.4.orig/src/common/function.h0000644000175000017500000000212711365502244020731 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void create_function(_symbol *symbol, int type); void add_arg(_symbol* symbol, int type); void end_args(void); void add_local(_symbol* symbol); void check_return(int type); void end_function(void); void restore_variables(void); void init_call(_symbol *symbol); void end_call(void); void lift_param(int type); eukleides-1.5.4.orig/src/common/triangle.h0000644000175000017500000000220211365502244020703 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void define_optimal_scalene(_param p); void define_triangle_SSS(_param p); void define_triangle_SAA(_param p); void define_triangle_SAS(_param p); void define_triangle_SSA(_param p); void define_right_SS(_param p); void define_right_SA(_param p); void define_isoceles_SS(_param p); void define_isoceles_SA(_param p); void define_equilateral(_param p); eukleides-1.5.4.orig/src/common/symbol.h0000644000175000017500000000376311365502244020420 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ typedef struct symbol _symbol; typedef struct { int type; _symbol *arg; } _argument; typedef struct { int addr; _argument *arg_tbl; _argument *last_arg; _symbol **loc_tbl; _symbol **last_loc; } _function; typedef struct { double x; double y; } _point; typedef struct { double x; double y; } _vector; typedef struct set _set; struct set { _point *p; _set *next; }; typedef struct { double x; double y; double a; } _line; typedef struct { double x; double y; double r; } _circle; typedef struct { double x; double y; double d; double a; double b; int type; } _conic; typedef union { double number; _point *point; _vector *vector; _set *set; _line *line; _circle *circle; _conic *conic; char *string; _function func; } _value; typedef struct content _content; struct content { int type; _value value; _content *next; }; struct symbol { char *symbol; int index; _content *content; _symbol *next; }; void init_symbol_list(void); void add_symbol(char *symbol, int type); _symbol *update_table(char *symbol); void clear_entry(_symbol *entry); void clear_table(void); eukleides-1.5.4.orig/src/common/keywords.c0000644000175000017500000001136311365502244020750 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, add to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "args.h" #include "symbol.h" #include "parser.tab.h" #define __(str,id) add_symbol(str,id) void load_keywords(void) { __("abs", ABS_); __("abscissa", ABSCISSA); __("acos", ACOS); __("altitude", ALTITUDE); __("and", AND); __("angle", ANGLE); __("append", APPEND); __("area", AREA); __("arg", ARG); __("arrow", ARROW); __("arrows", ARROWS); __("asin", ASIN); __("atan", ATAN); __("back", BACK); __("barycenter", BARYCENTER); __("bisector", BISECTOR); __("black", BLACK); __("blue", BLUE); __("box", BOX); __("card", CARD); __("cat", CAT); __("ceil", CEIL); __("center", CENTER); __("centroid", CENTROID); __("circle", CIRCLE); __("clamp", CLAMP_); __("clear", CLEAR); __("close", CLOSE); __("collinear", COLLINEAR); __("conic", CONIC); __("cos", COS); __("cross", CROSS); __("cyan", CYAN); __("darkgray", DARKGRAY); __("dashed", DASHED); __("deg", DEG); __("disc", DISC); __("display", DISPLAY); __("distance", DISTANCE); __("dot", DOT); __("dotted", DOTTED); __("double", DOUBLE); __("draw", DRAW); __("eccentricity", ECCENTRICITY); __("element", ELEMENT); __("ellipse", ELLIPSE); __("else", ELSE); __("elseif", ELSEIF); __("empty", EMPTY); __("end", END); __("entire", ENTIRE); __("eps", EPS); __("equilateral", EQUILATERAL); __("error", ERROR); __("exp", EXP); __("false", FALSE); __("floor", FLOOR); __("foci", FOCI); __("font", FONT); __("for", FOR); __("forth", FORTH); __("frame", FRAME); __("full", FULL); __("gray", GRAY); __("green", GREEN); __("half", HALF); __("height", HEIGHT); __("hexagon", HEXAGON); __("homothecy", HOMOTHECY); __("horizontal", HORIZONTAL); __("hyperbola", HYPERBOLA); __("if", IF); __("in", IN); __("incircle", INCIRCLE); __("intersection", INTERSECTION); __("isobarycenter", ISOBARYCENTER); __("isosceles", ISOSCELES); __("label", LABEL); __("length", LENGTH); __("lightgray", LIGHTGRAY); __("line", LINE); __("ln", LN); __("local", LOCAL); __("locus", LOCUS); __("magenta", MAGENTA); __("major", MAJOR); __("max", MAX_); __("median", MEDIAN); __("midpoint", MIDPOINT); __("min", MIN_); __("minor", MINOR); __("mobile", MOBILE); __("mod", MOD); __("none", NONE); __("not", NOT); __("number", NUMBER); __("on", ON); __("or", OR); __("ordinate", ORDINATE); __("orthocenter", ORTHOCENTER); __("output", OUTPUT); __("parabola", PARABOLA); __("parallel", PARALLEL); __("parallelogram", PARALLELOGRAM); __("pentagon", PENTAGON); __("perimeter", PERIMETER); __("perpendicular", PERPENDICULAR); __("pi", PI_); __("plus", PLUS); __("point", POINT); __("polygon", POLYGON); __("print", PRINT); __("projection", PROJECTION); __("pstricks", PSTRICKS); __("put", PUT); __("rad", RAD); __("radius", RADIUS); __("read", READ); __("rectangle", RECTANGLE); __("red", RED); __("reflection", REFLECTION); __("release", RELEASE); __("return", RETURN); __("right", RIGHT); __("rotation", ROTATION); __("round", ROUND); __("scale", SCALE); __("set", SET); __("sign", SIGN); __("simple", SIMPLE); __("sin", SIN); __("sqrt", SQRT); __("square", SQUARE); __("step", STEP); __("stop", STOP); __("string", STRING); __("sub", SUB); __("symmetric", SYMMETRIC); __("tan", TAN); __("to", TO); __("translation", TRANSLATION); __("triangle", TRIANGLE); __("triple", TRIPLE); __("true", TRUE); __("vector", VECTOR); __("vertical", VERTICAL); __("while", WHILE); __("white", WHITE); __("write", WRITE); __("yellow", YELLOW); } eukleides-1.5.4.orig/src/common/circle.h0000644000175000017500000000231211365502244020341 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void create_circle_with_radius(void); void circle_center(void); void create_circle_with_diameter(void); void create_circumcircle(void); void create_incircle(void); void translate_circle(void); void reflect_circle(void); void symetric_circle(void); void rotate_circle(void); void homothetic_circle(void); void circle_radius(void); void circle_perimeter(void); void circle_area(void); void point_on_circle_argument(void); eukleides-1.5.4.orig/src/common/error.h0000644000175000017500000000176111365502244020240 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define _(str) str void fatal_error(char *msg); void yyerror(char *msg); void runtime_error(char *msg); void check_ptr(void *ptr); #define check_mem(ptr) check_ptr((void *)(ptr)) void print_warning(char *msg); eukleides-1.5.4.orig/src/common/core.h0000644000175000017500000000351711365502244020040 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ typedef union { void *ptr; double num; int addr; } _param; void init_stack_machine(void); void push_param(_param p); #define PSHn(num) push_param((_param)(num)) #define PSH(addr) push_param((_param)((void *)addr)) _param pop_param(void); #define POPn pop_param().num #define POPs (char *)pop_param().ptr #define POP(type) (type *)pop_param().ptr typedef struct { #ifdef __debug__ const char* inst; int arg; #endif void (*func)(); _param param; } _instr; typedef struct { _instr *tbl; _instr *last; _instr *end; _instr *cur; } _itable; void resize_instr_table(void); void goto_addr(_param p); void gosub_addr(_param p); void go_back(void); void jump_if_zero(_param p); void stop(void); void set_cur_line(_param p); void set_cur_file(_param p); void exec_itable(void); void reset_stack_machine(void); void *allocate(int size); #define get_mem(var,type) var = (type *)allocate(sizeof(type)) #define get_elem(var) \ var = (_set *)allocate(sizeof(_set)); \ var->p = (_point *)allocate(sizeof(_point)) eukleides-1.5.4.orig/src/common/vector.c0000644000175000017500000000722511365502244020405 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; fromout even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along from this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "symbol.h" #include "core.h" #include "utils.h" void create_vector_cartesian(void) { _vector *val; get_mem(val, _vector); val->y = POPn; val->x = POPn; PSH(val); } void create_vector_polar(void) { double r, a; _vector *val; get_mem(val, _vector); a = POPn; r = POPn; val->x = r*Cos(a); val->y = r*Sin(a); PSH(val); } void create_vector_from_points(void) { _point *A, *B; _vector *val; get_mem(val, _vector); B = POP(_point); A = POP(_point); val->x = B->x - A->x; val->y = B->y - A->y; PSH(val); } void create_vector_from_segment(void) { _set *set; _point *A, *B; _vector *val; set = POP(_set); A = get_point(&set); B = get_point(&set); get_mem(val, _vector); val->x = B->x - A->x; val->y = B->y - A->y; PSH(val); } void create_vector_from_line(void) { _line *l; _vector *val; get_mem(val, _vector); l = POP(_line); val->x = Cos(l->a); val->y = Sin(l->a); PSH(val); } void add_vectors(void) { _vector *val, *u, *v; get_mem(val, _vector); v = POP(_vector); u = POP(_vector); val->x = u->x + v->x; val->y = u->y + v->y; PSH(val); } void substract_vectors(void) { _vector *val, *u, *v; get_mem(val, _vector); v = POP(_vector); u = POP(_vector); val->x = u->x - v->x; val->y = u->y - v->y; PSH(val); } void reverse_vector(void) { _vector *val, *u; get_mem(val, _vector); u = POP(_vector); val->x = -u->x; val->y = -u->y; PSH(val); } void multiply_vector(void) { _vector *val, *u; double k; get_mem(val, _vector); u = POP(_vector); k = POPn; val->x = k * u->x; val->y = k * u->y; PSH(val); } void divide_vector(void) { _vector *val, *u; double k; get_mem(val, _vector); k = POPn; u = POP(_vector); val->x = u->x/k; val->y = u->y/k; PSH(val); } void rotate_vector(void) { _vector *val, *u; double l, a; get_mem(val, _vector); a = POPn; u = POP(_vector); a += RTOD(atan2(u->y, u->x)); l = hypot(u->x, u->y); val->x = l*Cos(a); val->y = l*Sin(a); PSH(val); } void vector_abscissa(void) { PSHn((POP(_vector))->x); } void vector_ordinate(void) { PSHn((POP(_vector))->y); } void vector_length(void) { _vector *u; u = POP(_vector); PSHn(hypot(u->x, u->y)); } void vector_argument(void) { _vector *u; u = POP(_vector); PSHn(RTOD(atan2(u->y, u->x))); } void vectors_angle(void) { _vector *u, *v; v = POP(_vector); u = POP(_vector); PSHn((u->x*v->y > u->y*v->x ? 1 : -1) * Acos((u->x*v->x+u->y*v->y)/(hypot(u->x, u->y)*hypot(v->x, v->y)))); } void scalar_product(void) { _vector *u, *v; v = POP(_vector); u = POP(_vector); PSHn(u->x*v->x + u->y*v->y); } eukleides-1.5.4.orig/src/common/number.h0000644000175000017500000000251311365502244020373 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void add(void); void substract(void); void multiply(void); void divide(void); void modulo(void); void change_sign(void); void square_root(void); void power(void); void exponential(void); void logarithm(void); void rtod(void); void dtor(void); void sine(void); void cosine(void); void tangent(void); void arcsine(void); void arccosine(void); void arctangent(void); void absolute_value(void); void sign(void); void ceil_value(void); void floor_value(void); void round_value(void); void minimum(void); void maximum(void); void clamp(void); eukleides-1.5.4.orig/src/common/function.c0000644000175000017500000000742311365502244020730 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "error.h" #include "core.h" #include "symbol.h" #include "parser.tab.h" #include "compiler.h" #include "variable.h" _function *func; int func_type; #define MAX_ARGS 32 #define MAX_LOCALS 32 void create_function(_symbol *symbol, int type) { if (func != NULL) yyerror(_("invalid function definition")); set_type(symbol, type); func_type = type; func = &symbol->content->value.func; func->addr = get_addr() + 1; func->arg_tbl = (_argument *)allocate(MAX_ARGS*sizeof(_argument *)); check_mem(func->arg_tbl); func->last_arg = func->arg_tbl; func->loc_tbl = (_symbol **)allocate(MAX_LOCALS*sizeof(_symbol *)); check_mem(func->loc_tbl); func->last_loc = func->loc_tbl; } void add_arg(_symbol* symbol, int type) { func->last_arg->arg = symbol; func->last_arg->type = type; func->last_arg++; if (func->last_arg - func->arg_tbl == MAX_ARGS) yyerror(_("too many arguments")); lift_type(symbol, type); } void end_args(void) { func->last_arg->type = END; } void add_local(_symbol* symbol) { if (func == NULL) yyerror(_("invalid local declaration")); *(func->last_loc++) = symbol; if (func->last_loc - func->loc_tbl == MAX_LOCALS) yyerror(_("too many arguments")); lift_type(symbol, SYMBOL); XEQ(lift_sym, symbol); } void check_return(int type) { if (type != func_type) yyerror(_("invalid return statement")); } void restore_table(_function func) { _argument *cur; _symbol **sym; for (cur = func.arg_tbl ; cur < func.last_arg; cur++) drop((_param)(void *)cur->arg); for (sym = func.loc_tbl ; sym < func.last_loc; sym++) drop((_param)(void *)*sym); } void return_error(void) { runtime_error(_("function ending without return statement")); } void end_function(void) { restore_table(*func); func = NULL; if (func_type == COMMAND) RTN; else XEQ_(return_error); func_type = 0; } void restore_variables(void) { restore_table(((_symbol *)pop_param().ptr)->content->value.func); } #define MAX_CALLS 32 _argument *call[MAX_CALLS]; int ind = -1; void init_call(_symbol *symbol) { if (++ind == MAX_CALLS) yyerror(_("too many overlapping calls")); call[ind] = symbol->content->value.func.arg_tbl; } void lift_param(int type) { if (call[ind]->type == END) yyerror(_("too many parameters")); if (call[ind]->type != type) yyerror(_("wrong parameter type")); switch(type) { case _NUMBER: XEQ(lift_num, call[ind]->arg); break; case _POINT: XEQ(lift_pnt, call[ind]->arg); break; case _VECTOR: XEQ(lift_vec, call[ind]->arg); break; case _SET: XEQ(lift_set, call[ind]->arg); break; case _LINE: XEQ(lift_lin, call[ind]->arg); break; case _CIRCLE: XEQ(lift_cir, call[ind]->arg); break; case _CONIC: XEQ(lift_con, call[ind]->arg); break; case _STRING: XEQ(lift_str, call[ind]->arg); break; } call[ind]++; } void end_call(void) { if (call[ind]->type != END) yyerror(_("too few parameters")); ind--; } eukleides-1.5.4.orig/src/common/setting.c0000644000175000017500000001220011365502244020545 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "args.h" #include "symbol.h" #include "core.h" #include "compiler.h" #include "parser.tab.h" /* Box and scale */ double min_x = -2, min_y = -2, max_x = 8, max_y = 6, scale = 1; void set_scale(void) { scale = POPn; if (scale <= 0) runtime_error(_("invalid scale factor")); } void set_box(_param p) { set_scale(); max_y = POPn; max_x = POPn; min_y = POPn; min_x = POPn; if (max_x <= min_x || max_y <= min_y) runtime_error(_("invalid bounding box")); } /* Color */ int global_color = BLACK; int local_color = BLACK; void set_global_color(_param p) { global_color = local_color = p.addr; } void set_local_color(_param p) { local_color = p.addr; } /* Size */ double global_size = 1; double local_size = 1; void set_global_size(_param p) { global_size = local_size = p.num; if (global_size <= 0) runtime_error(_("invalid size")); } void set_local_size(_param p) { local_size = p.num; if (local_size <= 0) runtime_error(_("invalid size")); } /* Step */ double global_step = 3; double local_step = 3; void set_global_step(void) { global_step = local_step = POPn; if (global_step <= 0) runtime_error(_("invalid size")); } void set_local_step(void) { local_step = POPn; if (local_step <= 0) runtime_error(_("invalid size")); } /* Line style */ int global_style = FULL; int local_style = FULL; void set_global_style(_param p) { global_style = local_style = p.addr; } void set_local_style(_param p) { local_style = p.addr; } /* Point shape */ int global_shape = DOT; int local_shape = DOT; void set_global_shape(_param p) { global_shape = local_shape = p.addr; } void set_local_shape(_param p) { local_shape = p.addr; } /* Line partition */ int global_part = ENTIRE; int local_part = ENTIRE; void set_global_part(_param p) { global_part = local_part = p.addr; } void set_local_part(_param p) { local_part = p.addr; } /* Direction */ int global_dir = FORTH; int local_dir = FORTH; void set_global_dir(_param p) { global_dir = local_dir = p.addr; } void set_local_dir(_param p) { local_dir = p.addr; } /* Arrows */ int global_arrow = NONE; int local_arrow = NONE; void set_global_arrow(_param p) { global_arrow = local_arrow = p.addr; } void set_local_arrow(_param p) { local_arrow = p.addr; } /* Font */ char *global_font_desc; char *local_font_desc; int global_font = 0; int local_font = 0; void set_global_font(void) { global_font_desc = local_font_desc = POPs; global_font = 1; } void set_local_font(void) { local_font_desc = POPs; local_font = 1; } /* Segment label style */ int global_segment = SIMPLE; int local_segment = SIMPLE; void set_global_segment(_param p) { global_segment = local_segment = p.addr; } void set_local_segment(_param p) { local_segment = p.addr; } /* Angle label style */ int global_angle = SIMPLE; int local_angle = SIMPLE; void set_global_angle(_param p) { global_angle = local_angle = p.addr; } void set_local_angle(_param p) { local_angle = p.addr; } /* Angle label decoration */ int global_dec = NONE; int local_dec = NONE; void set_global_dec(_param p) { global_dec = local_dec = p.addr; } void set_local_dec(_param p) { local_dec = p.addr; } /* Global and local settings */ int global_settings = 0; int local_settings = 0; void restore_default_settings(void) { global_style = local_style = FULL; global_shape = local_shape = DOT; global_part = local_part = ENTIRE; global_dir = local_dir = FORTH; global_arrow = local_arrow = NONE; global_color = local_color = BLACK; global_size = local_size = 1; global_step = local_step = 3; global_font = local_font = 0; global_segment = local_segment = SIMPLE; global_angle = local_angle = SIMPLE; global_dec = local_dec = NONE; } void restore_global_settings(void) { local_style = global_style; local_shape = global_shape; local_part = global_part; local_dir = global_dir; local_arrow = global_arrow; local_color = global_color; local_size = global_size; local_step = global_step; local_font = 0; local_segment = global_segment; local_angle = global_angle; local_dec = global_dec; } void clear_local_settings(void) { if (local_settings) { XEQ_(restore_global_settings); local_settings = 0; } } eukleides-1.5.4.orig/src/common/draw.h0000644000175000017500000000241411365502244020040 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ int preamble; void put_preamble(void); void put_closing(void); void draw_point(void); void draw_vector(void); void draw_path(void); void draw_polygon(void); void fill_polygon(void); void hatch_polygon(void); void draw_line(void); void draw_circle(void); void draw_arc(void); void fill_circle(void); void hatch_circle(void); void draw_conic(void); void draw_conic_arc(void); void draw_string(_param p); void label_segment(void); void label_angle(void); void label_point(_param p); eukleides-1.5.4.orig/src/common/parser.y0000644000175000017500000011722611365502244020430 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ %{ #include #include #include #include "error.h" #include "args.h" #include "module.h" #include "symbol.h" #include "core.h" #include "compiler.h" #include "variable.h" #include "function.h" #include "number.h" #include "point.h" #include "vector.h" #include "set.h" #include "line.h" #include "circle.h" #include "conic.h" #include "strings.h" #include "test.h" #include "triangle.h" #include "quadrilateral.h" #include "intersection.h" #include "locus.h" #include "interactive.h" #include "io.h" #include "setting.h" #include "draw.h" #include "check.h" int yylex(void); %} %union { double number; _point *point; _vector *vector; _set *set; _line *line; _circle *circle; _conic *conic; char *string; int boolean; int setting; int state; _symbol *ptr; }; %token CONST_NUM %token CONST_STR MODULE %token TRUE FALSE %token FULL DOTTED DASHED DOT DISC BOX PLUS CROSS %token ENTIRE HALF FORTH BACK NONE ARROW ARROWS %token BLACK DARKGRAY GRAY LIGHTGRAY WHITE %token RED GREEN BLUE CYAN MAGENTA YELLOW %token SIMPLE DOUBLE TRIPLE RIGHT %token STATE %token SYMBOL _NUMBER _POINT _VECTOR _SET %token _LINE _CIRCLE _CONIC _STRING LOCKED %token COMMAND NUM_FUNC PNT_FUNC VEC_FUNC SET_FUNC %token LIN_FUNC CIR_FUNC CON_FUNC STR_FUNC %token ABS_ ABSCISSA ACOS ALTITUDE ANGLE APPEND AREA ARG ASIN ATAN BARYCENTER %token BISECTOR CARD CAT CEIL CENTER CENTROID CIRCLE CLAMP_ CLEAR CLOSE %token COLLINEAR CONIC COS DEG DISPLAY DISTANCE DRAW ECCENTRICITY ELEMENT %token ELLIPSE EMPTY END EPS EQUILATERAL ERROR EXP FLOOR FOCI FONT FOR FRAME %token HEIGHT HEXAGON HOMOTHECY HORIZONTAL HYPERBOLA IF ISOBARYCENTER IN %token INCIRCLE INTERSECTION ISOSCELES LABEL LENGTH LINE LN LOCAL LOCUS MAJOR %token MAX_ MEDIAN MIDPOINT MIN_ MINOR MOBILE NUMBER ON ORDINATE ORTHOCENTER %token OUTPUT PARABOLA PARALLEL PARALLELOGRAM PENTAGON PERIMETER PRINT %token PERPENDICULAR PI_ POINT POLYGON PROJECTION PSTRICKS PUT RAD RADIUS READ %token RECTANGLE REFLECTION RELEASE RETURN ROTATION ROUND SCALE SET SIGN SIN %token SQRT SQUARE STEP STOP STRING SUB SYMMETRIC TAN TO TRANSLATION TRIANGLE %token VECTOR VERTICAL WHILE WRITE %right '.' %right '?' '|' %left OR %left AND %left NOT %left EQ NEQ %left LEQ GEQ %left '<' '>' %left '-' '+' %left '*' '/' %left MOD %left NEG %right '^' %nonassoc THEN %nonassoc ELSE %nonassoc ELSEIF %type num_exp %type pnt_exp %type vec_exp %type set_exp %type lin_exp %type cir_exp %type con_exp %type str_exp %type assertion %type style_setting shape_setting part_setting dir_setting %type arrow_setting color_setting common_setting segment_setting %type angle_setting dec_setting %type variable variable_in_use not_a_point %% input: { XEQ(set_cur_file, input_name); SET_(set_cur_line, 1); } block { if (preamble) XEQ_(put_closing); } ; block: statement | block nl statement ; nl: '\n' { SET_(set_cur_line, get_lineno()); } | ';' { /* Nothing to do */ } | MODULE { XEQ(set_cur_file, $1); SET_(set_cur_line, get_lineno()); } ; statement: | declaration | local | definition | locus | interactive | assignment | command | test | loop | drawing ; declaration: header { GTO(0); store_mark(); } '(' arg_def ')' { end_args(); } block END { end_function(); back_patch(); } ; header: variable { create_function($1, COMMAND); } | NUMBER variable { create_function($2, NUM_FUNC); } | POINT variable { create_function($2, PNT_FUNC); } | VECTOR variable { create_function($2, VEC_FUNC); } | SET variable { create_function($2, SET_FUNC); } | LINE variable { create_function($2, LIN_FUNC); } | CIRCLE variable { create_function($2, CIR_FUNC); } | CONIC variable { create_function($2, CON_FUNC); } | STRING variable { create_function($2, STR_FUNC); } ; variable_in_use: _NUMBER | _POINT | _VECTOR | _SET | _LINE | _CIRCLE | _CONIC | _STRING ; variable: SYMBOL | variable_in_use ; arg_def: /* Empty */ | arg_list ; arg_list: argument | arg_list ',' argument ; argument: NUMBER variable { add_arg($2, _NUMBER); } | POINT variable { add_arg($2, _POINT); } | VECTOR variable { add_arg($2, _VECTOR); } | SET variable { add_arg($2, _SET); } | LINE variable { add_arg($2, _LINE); } | CIRCLE variable { add_arg($2, _CIRCLE); } | CONIC variable { add_arg($2, _CONIC); } | STRING variable { add_arg($2, _STRING); } ; local: LOCAL local_list; local_list: local_var | local_var ',' local_list ; local_var: variable { add_local($1); } ; not_a_point: SYMBOL | _NUMBER | _VECTOR | _SET | _LINE | _CIRCLE | _CONIC | _STRING ; definition: not_a_point not_a_point not_a_point { set_type($1, _POINT); set_type($2, _POINT); set_type($3, _POINT); PSH_((void *)$3); PSH_((void *)$2); PSH_((void *)$1); } triangle_0 | _POINT not_a_point not_a_point { set_type($2, _POINT); set_type($3, _POINT); PSH_((void *)$3); PSH_((void *)$2); XEQ(recall_pnt, $1); } triangle_1 | _POINT _POINT not_a_point { set_type($3, _POINT); PSH_((void *)$3); XEQ(recall_pnt, $2); XEQ(recall_pnt, $1); } triangle_2 | not_a_point not_a_point not_a_point not_a_point { set_type($1, _POINT); set_type($2, _POINT); set_type($3, _POINT); set_type($4, _POINT); PSH_((void *)$4); PSH_((void *)$3); PSH_((void *)$2); PSH_((void *)$1); } quadrilateral_0 | _POINT not_a_point not_a_point not_a_point { set_type($2, _POINT); set_type($3, _POINT); set_type($4, _POINT); PSH_((void *)$4); PSH_((void *)$3); PSH_((void *)$2); XEQ(recall_pnt, $1); } quadrilateral_1 | _POINT _POINT not_a_point not_a_point { set_type($3, _POINT); set_type($4, _POINT); PSH_((void *)$4); PSH_((void *)$3); XEQ(recall_pnt, $2); XEQ(recall_pnt, $1); } quadrilateral_2 | _POINT _POINT _POINT not_a_point { set_type($4, _POINT); PSH_((void *)$4); XEQ(recall_pnt, $3); XEQ(recall_pnt, $2); XEQ(recall_pnt, $1); } PARALLELOGRAM { XEQ(define_parallelogram_SSA, 3); } ; triangle_0: TRIANGLE base_arguments { XEQ(define_optimal_scalene, 0); } | TRIANGLE triangle_SSS { XEQ(define_triangle_SSS, 0); } | TRIANGLE triangle_SAA { XEQ(define_triangle_SAA, 0); } | TRIANGLE triangle_SAS { XEQ(define_triangle_SAS, 0); } | TRIANGLE triangle_SSA { XEQ(define_triangle_SSA, 0); } | RIGHT right_SS { XEQ(define_right_SS, 0); } | RIGHT right_SA { XEQ(define_right_SA, 0); } | ISOSCELES isosceles_SS { XEQ(define_isoceles_SS, 0); } | ISOSCELES isosceles_SA { XEQ(define_isoceles_SA, 0); } | EQUILATERAL base_arguments { XEQ(define_equilateral, 0); } ; triangle_1: TRIANGLE base_arguments { XEQ(define_optimal_scalene, 1); } | TRIANGLE triangle_SSS { XEQ(define_triangle_SSS, 1); } | TRIANGLE triangle_SAA { XEQ(define_triangle_SAA, 1); } | TRIANGLE triangle_SAS { XEQ(define_triangle_SAS, 1); } | TRIANGLE triangle_SSA { XEQ(define_triangle_SSA, 1); } | RIGHT right_SS { XEQ(define_right_SS, 1); } | RIGHT right_SA { XEQ(define_right_SA, 1); } | ISOSCELES isosceles_SS { XEQ(define_isoceles_SS, 1); } | ISOSCELES isosceles_SA { XEQ(define_isoceles_SA, 1); } | EQUILATERAL base_arguments { XEQ(define_equilateral, 1); } ; triangle_2: TRIANGLE { XEQ(define_optimal_scalene, 2); } | TRIANGLE num_exp ',' num_exp { XEQ(define_triangle_SSS, 2); } | TRIANGLE ang_exp ',' ang_exp { XEQ(define_triangle_SAA, 2); } | TRIANGLE ang_exp ',' num_exp { XEQ(define_triangle_SAS, 2); } | TRIANGLE num_exp ',' ang_exp { XEQ(define_triangle_SSA, 2); } | RIGHT num_exp { XEQ(define_right_SS, 2); } | RIGHT ang_exp { XEQ(define_right_SA, 2); } | ISOSCELES num_exp { XEQ(define_isoceles_SS, 2); } | ISOSCELES ang_exp { XEQ(define_isoceles_SA, 2); } | EQUILATERAL { XEQ(define_equilateral, 2); } ; base_angle: ',' ang_exp { /* Nothing to do */ } | { PSH_(0.); } ; base_arguments: num_exp base_angle { /* Nothing to do */ } | /* Empty */ { PSH_(6.); PSH_(0.); } ; triangle_SSS: num_exp ',' num_exp ',' num_exp base_angle { /* Nothing to do */ } ; triangle_SAA: num_exp ',' ang_exp ',' ang_exp base_angle { /* Nothing to do */ } ; triangle_SAS: num_exp ',' ang_exp ',' num_exp base_angle { /* Nothing to do */ } ; triangle_SSA: num_exp ',' num_exp ',' ang_exp base_angle { /* Nothing to do */ } ; right_SS: num_exp ',' num_exp base_angle { /* Nothing to do */ } | /* Empty */ { PSH_(6.); PSH_(4.5); PSH_(0.); } ; right_SA: num_exp ',' ang_exp base_angle { /* Nothing to do */ } ; isosceles_SS: num_exp ',' num_exp base_angle { /* Nothing to do */ } ; isosceles_SA: num_exp ',' ang_exp base_angle { /* Nothing to do */ } | /* Empty */ { PSH_(6.); PSH_(39.); PSH_(0.); } ; quadrilateral_0: PARALLELOGRAM parallelogram_SSA { XEQ(define_parallelogram_SSA, 0); } | PARALLELOGRAM parallelogram_VV { XEQ(define_parallelogram_VV, 0); } | RECTANGLE rectangle_SS { XEQ(define_rectangle, 0); } | SQUARE square { XEQ(define_square, 0); } ; quadrilateral_1: PARALLELOGRAM parallelogram_SSA { XEQ(define_parallelogram_SSA, 1); } | PARALLELOGRAM parallelogram_VV { XEQ(define_parallelogram_VV, 1); } | RECTANGLE rectangle_SS { XEQ(define_rectangle, 1); } | SQUARE square { XEQ(define_square, 1); } ; quadrilateral_2: PARALLELOGRAM parallelogram_SA { XEQ(define_parallelogram_SSA, 2); } | RECTANGLE num_exp { XEQ(define_rectangle, 2); } | SQUARE { XEQ(define_square, 2); } ; parallelogram_SSA: num_exp ',' num_exp ',' ang_exp base_angle { /* Nothing to do */ } | /* Empty */ { PSH_(5.); PSH_(4.); PSH_(75.); PSH_(0.); } ; parallelogram_VV: vec_exp ',' vec_exp { /* Nothing to do */ } ; rectangle_SS: num_exp ',' num_exp base_angle { /* Nothing to do */ } | /* Empty */ { PSH_(6.); PSH_(3.7082039324994); PSH_(0.); } ; square: num_exp base_angle { /* Nothing to do */ } | /* Empty */ { PSH_(4.); PSH_(0.); } ; parallelogram_SA: num_exp ',' ang_exp { /* Nothing to do */ } ; locus: LOCUS variable '(' variable '=' num_exp TO num_exp step_number ')' { if (locus_addr != 0) yyerror(_("illegal locus definition")); set_type($2, LOCKED); set_type($4, _NUMBER); XEQ(init_locus, $4); locus_addr = get_addr(); JPZ(0); store_mark(); } block END { set_type($2, _SET); back_patch(); XEQ(store_set, $2); locus_addr = 0; } ; step_number: STEP num_exp { /* Nothing to do */ } | /* Empty */ { PSH_(120.); } ; interactive: MOBILE not_a_point mobile '=' pnt_exp { set_type($2, _POINT); XEQ(store_mobile, $2); } | MOBILE _POINT mobile { XEQ(recall_pnt, $2); XEQ(store_mobile, $2); } | HORIZONTAL variable '(' state inter_param ')' '=' num_exp { set_type($2, _NUMBER); PSH_(0); XEQ(store_interactive, $2); } | VERTICAL variable '(' state inter_param ')' '=' num_exp { set_type($2, _NUMBER); PSH_(1); XEQ(store_interactive, $2); } ; state: STATE { PSH_($1); } ; mobile: /* Empty */ { PSH_(0); } | '(' num_exp ')' { PSH_(1); } | '(' state ')' { PSH_(2); } | '(' state ',' num_exp ')' { PSH_(3); } | '(' num_exp ',' num_exp ',' num_exp ',' num_exp ')' { PSH_(4); } | '(' num_exp ',' num_exp ',' num_exp ',' num_exp ',' num_exp ')' { PSH_(5); } | '(' state ',' num_exp ',' num_exp ',' num_exp ',' num_exp ')' { PSH_(6); } | '(' state ',' num_exp ',' num_exp ',' num_exp ',' num_exp ',' num_exp ')' { PSH_(7); } ; inter_param: /* Empty */ { PSH_(0); } | ',' num_exp { PSH_(1); } | ',' num_exp ',' num_exp { PSH_(2); } | ',' num_exp ',' num_exp ',' num_exp { PSH_(3); } ; assignment: variable '=' num_exp { set_type($1, _NUMBER); XEQ(store_num, $1); } | variable '=' pnt_exp { set_type($1, _POINT); XEQ(store_pnt, $1); } | variable '=' vec_exp { set_type($1, _VECTOR); XEQ(store_vec, $1); } | variable '=' set_exp { set_type($1, _SET); XEQ(store_set, $1); } | variable_list '=' set_exp { XEQ_(multiple_store); } | _SET '[' num_exp ']' '=' pnt_exp { XEQ(store_at_index, $1); } | _SET '[' ']' '=' pnt_exp { XEQ(store_at_end, $1); } | variable '=' lin_exp { set_type($1, _LINE); XEQ(store_lin, $1); } | variable '=' cir_exp { set_type($1, _CIRCLE); XEQ(store_cir, $1); } | variable '=' con_exp { set_type($1, _CONIC); XEQ(store_con, $1); } | variable '=' str_exp { set_type($1, _STRING); XEQ(store_str, $1); } ; variable_list: variable '.' variable { set_type($1, _POINT); set_type($3, _POINT); PSH_(NULL); PSH_((void *)$3); PSH_((void *)$1); } | variable '.' variable_list { set_type($1, _POINT); PSH_((void *)$1); } ; num_exp: CONST_NUM { PSH_($1); } | _NUMBER { XEQ(recall_num, $1); } | num_exp '+' num_exp { XEQ_(add); } | num_exp '-' num_exp { XEQ_(substract); } | num_exp '*' num_exp { XEQ_(multiply); } | num_exp '/' num_exp { XEQ_(divide); } | num_exp MOD num_exp { XEQ_(modulo); } | '-' num_exp %prec NEG { XEQ_(change_sign); } | SQRT '(' num_exp ')' { XEQ_(square_root); } | num_exp '^' num_exp { XEQ_(power); } | EXP '(' num_exp ')' { XEQ_(exponential); } | LN '(' num_exp ')' { XEQ_(logarithm); } | PI_ { PSH_(M_PI); } | DEG '(' num_exp ')' { XEQ_(rtod); } | RAD '(' num_exp ')' { XEQ_(dtor); } | SIN '(' num_exp ')' { XEQ_(sine); } | COS '(' num_exp ')' { XEQ_(cosine); } | TAN '(' num_exp ')' { XEQ_(tangent); } | ASIN '(' num_exp ')' { XEQ_(arcsine); } | ACOS '(' num_exp ')' { XEQ_(arccosine); } | ATAN '(' num_exp ')' { XEQ_(arctangent); } | ABS_ '(' num_exp ')' { XEQ_(absolute_value); } | SIGN '(' num_exp ')' { XEQ_(sign); } | CEIL '(' num_exp ')' { XEQ_(ceil_value); } | FLOOR '(' num_exp ')' { XEQ_(floor_value); } | ROUND '(' num_exp ')' { XEQ_(round_value); } | MIN_ '(' num_exp ',' num_exp ')' { XEQ_(minimum); } | MAX_ '(' num_exp ',' num_exp ')' { XEQ_(maximum); } | CLAMP_ '(' num_exp ',' num_exp ',' num_exp ')' { XEQ_(clamp); } | ABSCISSA '(' pnt_exp ')' { XEQ_(point_abscissa); } | ORDINATE '(' pnt_exp ')' { XEQ_(point_ordinate); } | DISTANCE '(' pnt_exp ',' pnt_exp ')' { XEQ_(points_distance); } | ABSCISSA '(' vec_exp ')' { XEQ_(vector_abscissa); } | ORDINATE '(' vec_exp ')' { XEQ_(vector_ordinate); } | LENGTH '(' vec_exp ')' { XEQ_(vector_length); } | ARG '(' vec_exp ')' { XEQ_(vector_argument); } | ANGLE '(' vec_exp ',' vec_exp ')' { XEQ_(vectors_angle); } | vec_exp '*' vec_exp { XEQ_(scalar_product); } | CARD '(' set_exp ')' { XEQ_(set_cardinal); } | LENGTH '(' set_exp ')' { XEQ(path_length, 0); } | PERIMETER '(' set_exp ')' { XEQ(path_length, 1); } | AREA '(' set_exp ')' { XEQ_(polygon_area); } | ARG '(' set_exp ')' { XEQ_(segment_argument); } | ANGLE '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(vertex_angle); } | HEIGHT '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(triangle_height); } | DISTANCE '(' pnt_exp ',' lin_exp ')' { XEQ_(point_line_distance); } | ARG '(' lin_exp ')' { XEQ_(line_argument); } | RADIUS '(' cir_exp ')' { XEQ_(circle_radius); } | PERIMETER '(' cir_exp ')' { XEQ_(circle_perimeter); } | AREA '(' cir_exp ')' { XEQ_(circle_area); } | ARG '(' pnt_exp ',' cir_exp ')' { XEQ_(point_on_circle_argument); } | MAJOR '(' con_exp ')' { XEQ_(major_axis); } | MINOR '(' con_exp ')' { XEQ_(minor_axis); } | ECCENTRICITY '(' con_exp ')' { XEQ_(eccentricity); } | ARG '(' con_exp ')' { XEQ_(conic_argument); } | ARG '(' pnt_exp ',' con_exp ')' { XEQ_(point_on_conic_argument); } | assertion '?' num_exp '|' num_exp { XEQ_(ternary); } | LENGTH '(' str_exp ')' { XEQ_(str_length); } | NUMBER '(' ')' { PSH_(NULL); XEQ_(input_num); } | NUMBER '(' str_exp ')' { XEQ_(input_num); } | NUM_FUNC { init_call($1); } '(' param_decl ')' { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } | '(' num_exp ')' { /* Nothing to do */ } ; param_decl: /* Empty */ | param_list ; param_list: parameter | param_list ',' parameter ; parameter: num_exp { lift_param(_NUMBER); } | pnt_exp { lift_param(_POINT); } | vec_exp { lift_param(_VECTOR); } | set_exp { lift_param(_SET); } | lin_exp { lift_param(_LINE); } | cir_exp { lift_param(_CIRCLE); } | con_exp { lift_param(_CONIC); } | str_exp { lift_param(_STRING); } ; ang_exp: num_exp ':' { /* Nothing to do */ } | num_exp DEG { /* Nothing to do */ } | num_exp RAD { XEQ_(rtod); } ; pnt_exp: POINT '(' num_exp ',' num_exp ')' { XEQ_(create_point_cartesian); } | POINT '(' num_exp ',' ang_exp ')' { XEQ_(create_point_polar); } | POINT '(' set_exp ',' num_exp ')' { XEQ_(create_point_on_segment); } | POINT '(' lin_exp ',' num_exp ')' { XEQ_(create_point_on_line); } | ABSCISSA '(' lin_exp ',' num_exp ')' { XEQ_(create_point_with_abscissa); } | ORDINATE '(' lin_exp ',' num_exp ')' { XEQ_(create_point_with_ordinate); } | POINT '(' cir_exp ',' ang_exp ')' { XEQ_(create_point_on_circle); } | POINT '(' con_exp ',' ang_exp ')' { XEQ_(create_point_on_conic); } | MIDPOINT '(' set_exp ')' { XEQ_(create_midpoint); } | ISOBARYCENTER '(' set_exp ')' { XEQ_(create_isobarycenter); } | CENTROID '(' set_exp ')' { XEQ_(create_centroid); } | BARYCENTER { PSH_(NULL); PSH_(0.); } '(' barycenter_arg_list ')' { XEQ_(create_barycenter); } | ORTHOCENTER '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(create_orthocenter); } | CENTER '(' cir_exp ')' { XEQ_(circle_center); } | CENTER '(' con_exp ')' { XEQ_(conic_center); } | TRANSLATION '(' pnt_exp ',' vec_exp ')' { XEQ_(translate_point); } | REFLECTION '(' pnt_exp ',' lin_exp ')' { XEQ_(reflect_point); } | SYMMETRIC '(' pnt_exp ',' pnt_exp ')' { XEQ_(symetric_point); } | ROTATION '(' pnt_exp ',' pnt_exp ',' ang_exp ')' { XEQ_(rotate_point); } | HOMOTHECY '(' pnt_exp ',' pnt_exp ',' num_exp ')' { XEQ_(homothetic_point); } | PROJECTION '(' pnt_exp ',' lin_exp ')' { XEQ_(orthogonal_projection); } | PROJECTION '(' pnt_exp ',' lin_exp ',' lin_exp ')' { XEQ_(parallel_projection); } | INTERSECTION '(' lin_exp ',' lin_exp ')' { XEQ_(lines_intersection); } | ELEMENT '(' set_exp ',' num_exp ')' { XEQ(extract_point, NULL); } | _SET '[' num_exp ']' { XEQ(extract_point, $1); } | _POINT { XEQ(recall_pnt, $1); } | PNT_FUNC { init_call($1); } '(' param_decl ')' { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } ; barycenter_arg_list: arg_couple | barycenter_arg_list ',' arg_couple ; arg_couple: pnt_exp ',' num_exp { /* Nothing to do */ } ; vec_exp: VECTOR '(' num_exp ',' num_exp ')' { XEQ_(create_vector_cartesian); } | VECTOR '(' num_exp ',' ang_exp ')' { XEQ_(create_vector_polar); } | VECTOR '(' pnt_exp ',' pnt_exp ')' { XEQ_(create_vector_from_points); } | VECTOR '(' set_exp ')' { XEQ_(create_vector_from_segment); } | VECTOR '(' lin_exp ')' { XEQ_(create_vector_from_line); } | vec_exp '+' vec_exp { XEQ_(add_vectors); } | vec_exp '-' vec_exp { XEQ_(substract_vectors); } | '-' vec_exp %prec NEG { XEQ_(reverse_vector); } | num_exp '*' vec_exp { XEQ_(multiply_vector); } | vec_exp '/' num_exp { XEQ_(divide_vector); } | ROTATION '(' vec_exp ',' ang_exp ')' { XEQ_(rotate_vector); } | _VECTOR { XEQ(recall_vec, $1); } | VEC_FUNC { init_call($1); } '(' param_decl ')' { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } | '(' vec_exp ')' { /* Nothing to do */ } ; set_exp: SET '(' pnt_exp ')' { XEQ_(create_set); } | EMPTY { PSH_(NULL); } | set_exp '.' set_exp { XEQ_(catenate_sets); } | pnt_exp '.' set_exp { XEQ_(add_head_point); } | set_exp '.' pnt_exp { XEQ_(add_tail_point); } | pnt_exp '.' pnt_exp { XEQ_(create_segment); } | SUB '(' set_exp ',' num_exp ',' num_exp ')' { XEQ_(extract_subset); } | PENTAGON { PSH_(5.); } '(' pnt_exp ',' num_exp ',' ang_exp ')' { XEQ_(create_polygon); } | HEXAGON { PSH_(6.); } '(' pnt_exp ',' num_exp ',' ang_exp ')' { XEQ_(create_polygon); } | POLYGON '(' num_exp ',' pnt_exp ',' num_exp ',' ang_exp ')' { XEQ_(create_polygon); } | FOCI '(' con_exp ')' { XEQ_(conic_foci); } | TRANSLATION '(' set_exp ',' vec_exp ')' { XEQ_(translate_set); } | REFLECTION '(' set_exp ',' lin_exp ')' { XEQ_(reflect_set); } | SYMMETRIC '(' set_exp ',' pnt_exp ')' { XEQ_(symetric_set); } | ROTATION '(' set_exp ',' pnt_exp ',' ang_exp ')' { XEQ_(rotate_set); } | HOMOTHECY '(' set_exp ',' pnt_exp ',' num_exp ')' { XEQ_(homothetic_set); } | INTERSECTION '(' lin_exp ',' set_exp ')' { XEQ_(line_set_intersection); } | INTERSECTION '(' lin_exp ',' cir_exp ')' { XEQ_(line_circle_intersection); } | INTERSECTION '(' lin_exp ',' con_exp ')' { XEQ_(line_conic_intersection); } | INTERSECTION '(' set_exp ',' set_exp ')' { XEQ_(sets_intersection); } | INTERSECTION '(' cir_exp ',' cir_exp ')' { XEQ_(circles_intersection); } | INTERSECTION '(' cir_exp ',' set_exp ')' { XEQ_(circle_set_intersection); } | _SET { XEQ(recall_set, $1); } | SET_FUNC { init_call($1); } '(' param_decl ')' { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } ; lin_exp: LINE '(' pnt_exp ',' ang_exp ')' { XEQ_(create_line_with_argument); } | LINE '(' pnt_exp ',' pnt_exp ')' { XEQ_(create_line_with_points); } | LINE '(' pnt_exp ',' vec_exp ')' { XEQ_(create_line_with_vector); } | LINE '(' set_exp ')' { XEQ_(create_line_with_segment); } | LINE '(' cir_exp ',' ang_exp ')' { XEQ_(create_tangent_to_circle); } | LINE '(' con_exp ',' ang_exp ')' { XEQ_(create_tangent_to_conic); } | PARALLEL '(' lin_exp ',' pnt_exp ')' { XEQ_(create_parallel_to_line); } | PARALLEL '(' set_exp ',' pnt_exp ')' { XEQ_(create_parallel_to_segment); } | PERPENDICULAR '(' lin_exp ',' pnt_exp ')' { XEQ_(create_perpendicular_to_line); } | PERPENDICULAR '(' set_exp ',' pnt_exp ')' { XEQ_(create_perpendicular_to_segment); } | BISECTOR '(' set_exp ')' { XEQ_(create_perpendicular_bisector); } | BISECTOR '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(create_angle_bisector); } | BISECTOR '(' lin_exp ',' lin_exp ')' { XEQ_(create_lines_bisector); } | ALTITUDE '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(create_altitude); } | MEDIAN '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(create_median); } | TRANSLATION '(' lin_exp ',' vec_exp ')' { XEQ_(translate_line); } | REFLECTION '(' lin_exp ',' lin_exp ')' { XEQ_(reflect_line); } | SYMMETRIC '(' lin_exp ',' pnt_exp ')' { XEQ_(symetric_line); } | ROTATION '(' lin_exp ',' pnt_exp ',' ang_exp ')' { XEQ_(rotate_line); } | HOMOTHECY '(' lin_exp ',' pnt_exp ',' num_exp ')' { XEQ_(homothetic_line); } | _LINE { XEQ(recall_lin, $1); } | LIN_FUNC { init_call($1); } '(' param_decl ')' { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } ; cir_exp: CIRCLE '(' pnt_exp ',' num_exp ')' { XEQ_(create_circle_with_radius); } | CIRCLE '(' set_exp ')' { XEQ_(create_circle_with_diameter); } | CIRCLE '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(create_circumcircle); } | INCIRCLE '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(create_incircle); } | TRANSLATION '(' cir_exp ',' vec_exp ')' { XEQ_(translate_circle); } | REFLECTION '(' cir_exp ',' lin_exp ')' { XEQ_(reflect_circle); } | SYMMETRIC '(' cir_exp ',' pnt_exp ')' { XEQ_(symetric_circle); } | ROTATION '(' cir_exp ',' pnt_exp ',' ang_exp ')' { XEQ_(rotate_circle); } | HOMOTHECY '(' cir_exp ',' pnt_exp ',' num_exp ')' { XEQ_(homothetic_circle); } | _CIRCLE { XEQ(recall_cir, $1); } | CIR_FUNC { init_call($1); } '(' param_decl ')' { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } ; con_exp: ELLIPSE '(' pnt_exp ',' num_exp ',' num_exp ',' ang_exp ')' { XEQ_(create_ellipse); } | HYPERBOLA '(' pnt_exp ',' num_exp ',' num_exp ',' ang_exp ')' { XEQ_(create_hyperbola); } | PARABOLA '(' pnt_exp ',' num_exp ',' ang_exp ')' { XEQ_(create_parabola); } | PARABOLA '(' pnt_exp ',' lin_exp ')' { PSH_(1.); XEQ_(create_conic_with_directrix); } | CONIC '(' pnt_exp ',' lin_exp ',' num_exp ')' { XEQ_(create_conic_with_directrix); } | CONIC '(' pnt_exp ',' pnt_exp ',' num_exp ')' { XEQ_(create_conic_with_foci); } | TRANSLATION '(' con_exp ',' vec_exp ')' { XEQ_(translate_conic); } | REFLECTION '(' con_exp ',' lin_exp ')' { XEQ_(reflect_conic); } | SYMMETRIC '(' con_exp ',' pnt_exp ')' { XEQ_(symetric_conic); } | ROTATION '(' con_exp ',' pnt_exp ',' ang_exp ')' { XEQ_(rotate_conic); } | HOMOTHECY '(' con_exp ',' pnt_exp ',' num_exp ')' { XEQ_(homothetic_conic); } | _CONIC { XEQ(recall_con, $1); } | CON_FUNC { init_call($1); } '(' param_decl ')' { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } ; str_exp: CONST_STR { PSH_((void *)$1); } | STRING '(' ')' { PSH_(NULL); XEQ_(input_str); } | STRING '(' str_exp ')' { XEQ_(input_str); } | SUB '(' str_exp ',' num_exp ',' num_exp ')' { XEQ_(extract_substring); } | CAT { XEQ_(start_string); } '(' format_arg_list ')' { XEQ_(get_string); } | _STRING { XEQ(recall_str, $1); } | STR_FUNC { init_call($1); } '(' param_decl ')' { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } ; format_arg_list: format_arg | format_arg_list ',' format_arg ; format_arg: num_exp { XEQ_(cat_num); } | pnt_exp { XEQ_(cat_pnt); } | set_exp { XEQ_(cat_set); } | str_exp { XEQ_(cat_str); } ; command: print_command print_arg_list { XEQ_(print_nl); } | READ str_exp { XEQ_(open_read_mode); } | WRITE str_exp { XEQ_(open_write_mode); } | APPEND str_exp { XEQ_(open_append_mode); } | CLOSE { XEQ_(close_data_file); } | RELEASE { XEQ_(close_result_file); } | RETURN return_exp { RTN; } | PUT pnt_exp { if (locus_addr == 0) yyerror(_("illegal put statement")); XEQ_(put_pnt); GTO(locus_addr); } | BOX num_exp ',' num_exp ',' num_exp ',' num_exp scale_arg { XEQ(set_box, 0); } | FRAME num_exp ',' num_exp ',' num_exp ',' num_exp scale_arg { XEQ(set_box, 1); } | SCALE num_exp { XEQ_(set_scale); } | CLEAR variable_in_use { set_type($2, SYMBOL); } | COMMAND { init_call($1); } param_decl { end_call(); GSB($1->content->value.func.addr); PSH_((void *)$1); XEQ_(restore_variables); } | STOP { if (preamble) XEQ_(put_closing); STP; } ; scale_arg: ',' num_exp { /* Nothing to do */ } | /* Empty */ { PSH_(1.); } ; print_command: OUTPUT { XEQ_(put_preamble); preamble = 1; output = 0; } | PRINT { output = 1; } | ERROR { output = 2; } ; print_arg_list: print_arg | print_arg_list ',' print_arg ; print_arg: num_exp { XEQ_(print_num); } | pnt_exp { XEQ_(print_pnt); } | set_exp { XEQ_(print_set); } | str_exp { XEQ_(print_str); } ; return_exp: /* Empty */ { check_return(COMMAND); } | num_exp { check_return(NUM_FUNC); } | pnt_exp { check_return(PNT_FUNC); } | vec_exp { check_return(VEC_FUNC); } | set_exp { check_return(SET_FUNC); } | lin_exp { check_return(LIN_FUNC); } | cir_exp { check_return(CIR_FUNC); } | con_exp { check_return(CON_FUNC); } | str_exp { check_return(STR_FUNC); } ; test: IF if_block END; if_block: assertion then block %prec THEN { back_patch(); } | assertion then block ELSE { GTO(0); back_patch(); store_mark(); } block { back_patch(); } | assertion then block ELSEIF { GTO(0); back_patch(); store_mark(); } if_block { back_patch(); } ; then: { JPZ(0); store_mark(); } ; assertion: TRUE { PSH_(1); } | FALSE { PSH_(0); } | NOT assertion { XEQ_(not); } | assertion AND assertion { XEQ_(and); } | assertion OR assertion { XEQ_(or); } | num_exp EQ num_exp { XEQ_(num_eq); } | num_exp NEQ num_exp { XEQ_(num_neq); } | num_exp '<' num_exp { XEQ_(num_lt); } | num_exp LEQ num_exp { XEQ_(num_leq); } | num_exp '>' num_exp { XEQ_(num_gt); } | num_exp GEQ num_exp { XEQ_(num_geq); } | pnt_exp EQ pnt_exp { XEQ_(pnt_eq); } | pnt_exp NEQ pnt_exp { XEQ_(pnt_neq); } | COLLINEAR '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(collinear_points); } | vec_exp EQ vec_exp { XEQ_(vec_eq); } | vec_exp NEQ vec_exp { XEQ_(vec_neq); } | COLLINEAR '(' vec_exp ',' vec_exp ')' { XEQ_(collinear_vectors); } | set_exp EQ set_exp { XEQ_(set_eq); } | set_exp NEQ set_exp { XEQ_(set_neq); } | EMPTY '(' set_exp ')' { XEQ_(is_empty); } | pnt_exp ON set_exp { XEQ_(on_path); } | pnt_exp IN set_exp { XEQ_(in_set); } | lin_exp EQ lin_exp { XEQ_(lin_eq); } | lin_exp NEQ lin_exp { XEQ_(lin_neq); } | pnt_exp ON lin_exp { XEQ_(on_line); } | PARALLEL '(' lin_exp ',' lin_exp ')' { XEQ_(parallel_lines); } | PERPENDICULAR '(' lin_exp ',' lin_exp ')' { XEQ_(perpendicular_lines); } | cir_exp EQ cir_exp { XEQ_(cir_eq); } | cir_exp NEQ cir_exp { XEQ_(cir_neq); } | pnt_exp ON cir_exp { XEQ_(on_circle); } | con_exp EQ con_exp { XEQ_(con_eq); } | con_exp NEQ con_exp { XEQ_(con_neq); } | pnt_exp ON con_exp { XEQ_(on_conic); } | ELLIPSE '(' con_exp ')' { XEQ_(is_ellipse); } | HYPERBOLA '(' con_exp ')' { XEQ_(is_hyperbola); } | PARABOLA '(' con_exp ')' { XEQ_(is_parabola); } | str_exp EQ str_exp { XEQ_(str_eq); } | str_exp NEQ str_exp { XEQ_(str_neq); } | ISOSCELES '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(is_isosceles); } | EQUILATERAL '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(is_equilateral); } | RIGHT '(' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(is_right); } | PARALLELOGRAM '(' pnt_exp ',' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(is_parallelogram); } | RECTANGLE '(' pnt_exp ',' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(is_rectangle); } | SQUARE '(' pnt_exp ',' pnt_exp ',' pnt_exp ',' pnt_exp ')' { XEQ_(is_square); } | EPS { XEQ_(eps_output); } | PSTRICKS { XEQ_(pstricks_output); } | DISPLAY { XEQ_(display_output); } | '(' assertion ')' { /* Nothing to do */ } ; loop: WHILE { store_mark(); } assertion { JPZ(1); store_mark(); } block END { back_patch(); GTO(pop_mark()); } | FOR variable '=' num_exp { set_type($2, _NUMBER); XEQ(store_num, $2); store_mark(); } TO num_exp step { XEQ(recall_num, $2); XEQ_(for_test); JPZ(1); store_mark(); } block END { INC($2); back_patch(); GTO(pop_mark()); } | FOR variable IN set_exp { store_mark(); set_type($2, _POINT); XEQ_(push_point); JPZ(1); store_mark(); XEQ(store_pnt, $2); } block END { back_patch(); GTO(pop_mark()); } ; step: /* Empty */ { PSH_(1.); } | STEP num_exp { /* Nothing to do */ } ; drawing: DRAW { XEQ_(put_preamble); preamble = 1; } drawing_block { if (global_settings) { #ifdef __euktopst__ XEQ_(put_egroup); #endif XEQ_(restore_default_settings); global_settings = 0; } } | LABEL { XEQ_(put_preamble); preamble = 1; } label_block { if (global_settings) { XEQ_(restore_default_settings); global_settings = 0; } } ; drawing_block: drawable | drawing_settings nls drawable_list nls END; nls: nl | nls nl ; drawable_list: drawable | drawable_list nls drawable; drawing_settings: | drawing_setting | drawing_settings ',' drawing_setting ; drawing_setting: style_setting { SET_(set_global_style, $1); global_settings = 1; } | shape_setting { SET_(set_global_shape, $1); global_settings = 1; } | part_setting { SET_(set_global_part, $1); global_settings = 1; } | dir_setting { SET_(set_global_dir, $1); global_settings = 1; } | arrow_setting { SET_(set_global_arrow, $1); global_settings = 1; } | color_setting { SET_(set_global_color, $1); global_settings = 1; } | CONST_NUM { SET_(set_global_size, $1); global_settings = 1; } | ang_exp { XEQ_(set_global_step); global_settings = 1; } | FONT '(' str_exp ')' { XEQ_(set_global_font); global_settings = 1; } ; style_setting: FULL { $$ = FULL; } | DOTTED { $$ = DOTTED; } | DASHED { $$ = DASHED; } ; shape_setting: DOT { $$ = DOT; } | DISC { $$ = DISC; } | BOX { $$ = BOX; } | PLUS { $$ = PLUS; } | CROSS { $$ = CROSS; } ; part_setting: ENTIRE { $$ = ENTIRE; } | HALF { $$ = HALF; } ; dir_setting: FORTH { $$ = FORTH; } | BACK { $$ = BACK; } ; arrow_setting: NONE { $$ = NONE; } | ARROW { $$ = ARROW; } | ARROWS { $$ = ARROWS; } ; color_setting: BLACK { $$ = BLACK; } | DARKGRAY { $$ = DARKGRAY; } | GRAY { $$ = GRAY; } | LIGHTGRAY { $$ = LIGHTGRAY; } | WHITE { $$ = WHITE; } | RED { $$ = RED; } | GREEN { $$ = GREEN; } | BLUE { $$ = BLUE; } | CYAN { $$ = CYAN; } | MAGENTA { $$ = MAGENTA; } | YELLOW { $$ = YELLOW; } ; drawable: pnt_exp pnt_draw_settings { XEQ_(draw_point); clear_local_settings(); } | vec_exp pnt_exp basic_draw_settings { XEQ_(draw_vector); clear_local_settings(); } | set_exp path_draw_settings { XEQ_(draw_path); clear_local_settings(); } | '(' set_exp ')' basic_draw_settings { XEQ_(draw_polygon); clear_local_settings(); } | '[' set_exp ']' fill_setting { XEQ_(fill_polygon); clear_local_settings(); } | '[' set_exp ']' ang_exp hatch_settings { XEQ_(hatch_polygon); clear_local_settings(); } | lin_exp lin_draw_settings { XEQ_(draw_line); clear_local_settings(); } | cir_exp basic_draw_settings { XEQ_(draw_circle); clear_local_settings(); } | cir_exp ang_exp ang_exp path_draw_settings { XEQ_(draw_arc); clear_local_settings(); } | '[' cir_exp ']' fill_setting { XEQ_(fill_circle); clear_local_settings(); } | '[' cir_exp ']' ang_exp hatch_settings { XEQ_(hatch_circle); clear_local_settings(); } | con_exp con_draw_settings { XEQ_(draw_conic); clear_local_settings(); } | con_exp ang_exp ang_exp con_arc_draw_settings { XEQ_(draw_conic_arc); clear_local_settings(); } | str_exp pnt_exp ang_exp str_draw_settings { XEQ(draw_string, 0); clear_local_settings(); } | str_exp set_exp ang_exp str_draw_settings { XEQ(draw_string, 1); clear_local_settings(); } ; pnt_draw_settings: | pnt_draw_setting | pnt_draw_settings ',' pnt_draw_setting ; pnt_draw_setting: color_setting { SET_(set_local_color, $1); local_settings = 1; } | CONST_NUM { SET_(set_local_size, $1); local_settings = 1; } | shape_setting { SET_(set_local_shape, $1); local_settings = 1; } ; basic_draw_settings: | basic_draw_setting | basic_draw_settings ',' basic_draw_setting ; basic_draw_setting: color_setting { SET_(set_local_color, $1); local_settings = 1; } | CONST_NUM { SET_(set_local_size, $1); local_settings = 1; } | style_setting { SET_(set_local_style, $1); local_settings = 1; } ; path_draw_settings: | path_draw_setting | path_draw_settings ',' path_draw_setting ; path_draw_setting: basic_draw_setting { /* Nothing to do */ } | dir_setting { SET_(set_local_dir, $1); local_settings = 1; } | arrow_setting { SET_(set_local_arrow, $1); local_settings = 1; } ; con_draw_settings: | con_draw_setting | con_draw_settings ',' con_draw_setting ; con_draw_setting: basic_draw_setting { /* Nothing to do */ } | ang_exp { XEQ_(set_local_step); local_settings = 1; } ; con_arc_draw_settings: | con_arc_draw_setting | con_arc_draw_settings ',' con_arc_draw_setting ; con_arc_draw_setting: path_draw_setting { /* Nothing to do */ } | ang_exp { XEQ_(set_local_step); local_settings = 1; } ; fill_setting: | color_setting { SET_(set_local_color, $1); local_settings = 1; } ; hatch_settings: | hatch_setting | hatch_settings ',' hatch_setting ; hatch_setting: color_setting { SET_(set_local_color, $1); local_settings = 1; } | CONST_NUM { SET_(set_local_size, $1); local_settings = 1; } ; lin_draw_settings: | lin_draw_setting | lin_draw_settings ',' lin_draw_setting ; lin_draw_setting: basic_draw_setting { /* Nothing to do */ } | part_setting { SET_(set_local_part, $1); local_settings = 1; } | dir_setting { SET_(set_local_dir, $1); local_settings = 1; } ; str_draw_settings: | str_draw_setting | str_draw_settings ',' str_draw_setting ; str_draw_setting: color_setting { SET_(set_local_color, $1); local_settings = 1; } | CONST_NUM { SET_(set_local_size, $1); local_settings = 1; } | FONT '(' str_exp ')' { XEQ_(set_local_font); local_settings = 1; } ; label_block: label | label_settings nls label_list nls END; label_list: label | label_list nls label; label_settings: | label_setting | label_settings ',' label_setting ; label_setting: common_setting { SET_(set_global_segment, $1); SET_(set_global_angle, $1); global_settings = 1; } | segment_setting { SET_(set_global_segment, $1); global_settings = 1; } | angle_setting { SET_(set_global_angle, $1); global_settings = 1; } | dec_setting { SET_(set_global_dec, $1); global_settings = 1; } | color_setting { SET_(set_global_color, $1); global_settings = 1; } | CONST_NUM { SET_(set_global_size, $1); global_settings = 1; } | str_exp { XEQ_(set_global_font); global_settings = 1; } ; common_setting: SIMPLE { $$ = SIMPLE; } | DOUBLE { $$ = DOUBLE; } | TRIPLE { $$ = TRIPLE; } ; segment_setting: CROSS { $$ = CROSS; } ; angle_setting: RIGHT { $$ = RIGHT; } | FORTH { $$ = FORTH; } | BACK { $$ = BACK; } ; dec_setting: NONE { $$ = NONE; } | DOTTED { $$ = DOTTED; } | DASHED { $$ = DASHED; } ; label: set_exp seg_label_settings { XEQ_(label_segment); clear_local_settings(); } | pnt_exp ',' pnt_exp ',' pnt_exp ang_label_settings { XEQ_(label_angle); clear_local_settings(); } | _POINT ang_exp str_draw_settings { XEQ(label_point, $1); clear_local_settings(); } ; seg_label_settings: | seg_label_setting | seg_label_settings ',' seg_label_setting ; seg_label_setting: color_setting { SET_(set_local_color, $1); local_settings = 1; } | CONST_NUM { SET_(set_local_size, $1); local_settings = 1; } | common_setting { SET_(set_local_segment, $1); local_settings = 1; } | segment_setting { SET_(set_local_segment, $1); local_settings = 1; } ; ang_label_settings: | ang_label_setting | ang_label_settings ',' ang_label_setting ; ang_label_setting: color_setting { SET_(set_local_color, $1); local_settings = 1; } | CONST_NUM { SET_(set_local_size, $1); local_settings = 1; } | common_setting { SET_(set_local_angle, $1); local_settings = 1; } | angle_setting { SET_(set_local_angle, $1); local_settings = 1; } | dec_setting { SET_(set_local_dec, $1); local_settings = 1; } ; %% eukleides-1.5.4.orig/src/eukleides/0000755000175000017500000000000011365502244017413 5ustar robertlerobertleeukleides-1.5.4.orig/src/eukleides/main.c0000644000175000017500000000266211365502244020511 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "error.h" #include "args.h" #include "module.h" #include "keywords.h" #include "symbol.h" #include "strings.h" #include "core.h" #include "compiler.h" #include "interactive.h" #include "parser.tab.h" int yyparse(void); int main(int argc, char *argv[]) { process_args(argc, argv); load_keywords(); init_symbol_list(); init_string(); init_module_stack(); init_stack_machine(); yyparse(); if (anim_amount) for (anim_cur = 0; anim_cur < anim_amount; anim_cur++) { exec_itable(); strokes[anim_state][anim_dir] += anim_inc; } else exec_itable(); return EXIT_SUCCESS; } eukleides-1.5.4.orig/src/eukleides/args.c0000644000175000017500000000712611365502244020521 0ustar robertlerobertle/* * Eukleides version 1.5.4 * Copyright (c) Christian Obrecht 2004-2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #ifdef MO_DIR #include #include #endif #include "error.h" #include "core.h" #include "strings.h" void process_init_string(char *s); char *lang = "C"; char *input_name; char *output_name; char *data_name; FILE *output_file; int opt_output; int opt_batchmode; void print_version(void) { printf("Eukleides version 1.5.4\n" "Copyright (c) Christian Obrecht 2004-2010\n"); exit(EXIT_SUCCESS); } void print_help (void) { printf("Usage is: eukleides [