Algorithm: Drawing scheme

Source: Internet
Author: User

Directory

1. Introduction

2. Description of the problem

3. Solution Ideas

4. Solution

5. Code

1 Introduction

The idea of drawing a two-dimensional array diagram

2 Problem description

Given a drawing object's high-end, X-spacing, y-spacing, and initialization coordinates x, y draw m*n

3 Solution Ideas

The idea map is as follows

, at this time

401 Coordinates (0,0) 402 coordinates (x+ room width + pitch x,0) 403 coordinates for (x+ room width *2+ pitch x*2,0)

301 coordinates for (0,y+ room height + pitch y) 302 coordinates for (x+ room width + pitch x, y+ room height + pitch y)

303 (x+ room width *2+ pitch x*2, y+ room height + pitch y)

Let's say there's a floor.

Can get the coordinates of the nth room (x+ room width * (n-1) + pitch x* (n-1), y+ room height * (a-m) + pitch y* (a-m) in the section m floor

i.e. (x+ (broadly + pitch x) * (n-1), y+ (room height + pitch y) * (a-m))

4 Code

var x=0,y=0; Define initial coordinates x, y

var roomh=10,rooml=10; Define room height for Roomh, broadly for ROOML

var marginx=5,marginy=5; Define x-axis spacing: marginx,y axis spacing: marginy

var floortotal=4,roomsinfloor=3;//definition total number of floors floortotal, number of rooms per floor: Roomsinfloor

for (var m=floortotal;m>=1;m--)//Cycle floor

{

for (var n=1;n< roomsinfloor;n++)//number of circulating rooms

{

var roomx=x+ (Rooml+marginx) * (n-1);

var roomy=y+ (roomh+marginy) * (FLOORTOTAL-M);

}

}

Algorithm: Drawing scheme

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.